User tests: Successful: Unsuccessful:
This is sketch of <joomla-toolbar-button/>
.
It allow us to move most of inline onclick=""
to separate file.
From JavaScript side it mostly ready, but PHP require some more editing.
Any thoughts, is it need?
ping @dgt41 @C-Lodder
Status | New | ⇒ | Pending |
Category | ⇒ | JavaScript Repository Layout Libraries |
One issue with the current code we are using is that the "icon" name is tied to the button id. So for example in the sysinfo there is an a11y fail as the id is the same on both buttons because the icon is the same. it would be good if that could be avoided with this new code
would be awesome to implement is hide/show buttons depending on the selected rows of the list view
that also would be cool,
but it another complex task, I think will be better to separate this to 2 task, it more easy to test, and sync in case of conflict
@Fedik one more thing about accessibility:
It would be better if you create a button element and put the contents of the ce in there (button.innerHTML = this.innerHTML
).
The reason is that custom elements in fact are like span elements and since we want here to have all the good browser built in accessibility for buttons is better to create a button instead of manually patch the keyboard and mouse behaviours. To make this more clear try to tab to the buttons or enter/space when selected, we're missing crucial functionality here ;)
well it's not only tabindex you need to patch the key listeners as well. Basically because custom element extends HTMLElement
just extending the base Html element there is no special functionality there. In v0 of ce you could extend other elements like class Something extends HTMLButtonElement
, but I think this doesn't work anymore with v1
yes, that was another idea in my head,
should be no problem:
Labels |
Added:
?
?
|
@brianteeman the issue with non-unique ID is fixed
@dgt41 any idea why the link button use <button onlick="bla/link">
instead of a <a href="bla/link">
?
what to do with left over _getCommand() ?
keep it as is for B/C (with deprecate tag), or can just drop?
@Fedik one more thing here, a few months back I implemented a shortcut key handler for CTRL( or CMD)+S. That code somehow disappeared in some sync of the repos but you can check it here: joomla/40-backend-template#55. So it would be cool to have it back, probably it needs some changes as the codebase progressed a bit since
@dgt41 I have restored "control+s"
However if we can use one of these:
https://github.com/RobertWHurst/KeyboardJS
https://github.com/ccampbell/mousetrap
then I can integrate keyboard combos (shortcuts) to JoomlaToolbarButton
(instead of hardcoding in core.js
) that will allow to add own combos (one or multiple) to each toolbar button, in theory.
@Fedik the code was in core.js because we didn't have a toolbar.js or had a clue that custom elements was going to be part of J4 back then. Now the approach should be a little different IMHO:
in the CE before the class define a const like:
const keyboardSpecialKeys = (key, modifier, task) => {
if (modifier === 'control') { modifier = (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey); }
document.addEventListener("keydown", function(e) {
if (e.key === key && e.key === modifier ) {
e.preventDefault();
Joomla.submitbutton(task); // Pretty sure we can use submitForm here
}
}, false);
}
in the class connectedCallback function:
keyboardSpecialKeys(83, 'control', 'article.save')
Or you can use this.keyboardSpecialKeys(...)
if you get the function inside the class as another option.
The main point is that this functionality is tightly connected to the buttons (crtl+s is for save, but we can introduce more later) so I think the whole code should be in the custom elements.
I would not put too much stuff into this.
We can always add shortcuts and bonus stuff later.
But we should improve this a little:
There is no need to put the listselection logic INSIDE the custom element. This knowledge belongs in the outside world. A <joomla-toolbar-button>
is - depending on those or other outside conditions - either disabled, expanded, hidden or whatever. Imagine a "merge" button which merges 2 db entries. With the current implementation the button gets enabled when at least one item in the list is checked, which makes no sense. There is also no need to show the ugly alert to the user when he clicks a button he should not be able to click at all. UI should indicate (hidden/disabled) the state.
Something similar is true for the confirm attribute. Its not flexible enough. Perhaps we should put this into another element like <joomla-confirm-toolbar-button>
? Or implement some onBeforeSubmit
callback, where we can (later) replace the ugly browser confirm with a more user-friendly, modern confirmation dialog? Still new to custom elements and i dont know whats possible. Not that i expect you to implement a modern confirm dialog in this PR, but i think putting the confirm INSIDE the custom element is not flexible enough to fulfill the requirements of modern UIs.
I dont like that the toolbar button is coupled to a form and especially the form validation... The formvalidation should not depend on an attribute of a toolbar button... Could be also a candidate for an onBeforeSubmit Callback / Event (see above)... ?
There is no need to put the listselection logic INSIDE the custom element
I think it is fine,
but if there a better solution, then it can be better
Imagine a "merge" button which merges 2 db entries
There could be 3 db entries
for it we can make <joomla-toolbar-button list-selection="3"/>
or <joomla-toolbar-button list-selection="some fancy condition"/>
But it require extra work, and clear decision.
There is also no need to show the ugly alert to the user when he clicks a button he should not be able to click at all. UI should indicate (hidden/disabled) the state.
That actually what we have here disabled
state
Perhaps we should put this into another element like ? Or implement some onBeforeSubmit callback, where we can (later) replace the ugly browser confirm with a more user-friendly, modern confirmation dialog?
I would not do a Zoo of "toolbar-buttons" which on 90% will be copy of each other.
Technically <joomla-toolbar-button/>
is a wrapper around Joomla.submitbutton
which is made to be overridden by extension developer. So technically it is onBeforeSubmit
callback
I dont like that the toolbar button is coupled to a form and especially the form validation...
It is not very coupled.
There just a marker/flag which passed to Joomla.submitbutton
that say "I would like to validate the form". But the validation is in Joomla.submitbutton
, or where developer decide.
It allow to avoid hard-coding, like we have:
if ((task == 'cancel' ) || document.formvalidator.isValid( form))
Category | JavaScript Repository Layout Libraries | ⇒ | JavaScript Repository Layout Libraries Unit Tests |
I've merged the PHP API Updates which of course has made this blow up with conflicts. Can we get this back in sync
I will check
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-06-02 16:25:27 |
Closed_By | ⇒ | Fedik | |
Labels |
Added:
?
|
@Fedik one thing that would be awesome to implement is hide/show buttons depending on the selected rows of the list view. I started working on that idea so maybe something helpful there: https://github.com/joomla/joomla-cms/compare/4.0-dev...dgt41:ยง4.0-dev-toolbar-cleanup?expand=1
PS And yes this is needed to achieve CSP strict mode! Great stuff