-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(NcActionButton): Allow pressed state on NcActionButton - similar to NcButton #4744
Conversation
I think we went a bit away from showing the active state with a border at the left, no? But if it's approved, fine with me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, that’s correct @raimund-schluessler – the specs in the issue are quite old and from a time where we used that style.
Since we are generally close to Material Design, what they do is show a checkmark on the right – see "list item trailing icon" at https://m3.material.io/components/menus/specs
Then we also do not have any issues with contrast, regardless of the color.
Also, not sure if related, but in that example there is a bit too much whitespace below the last entry. It should be exactly the same as on the left and right (4px likely), but seems more.
No this is unrelated and a different issue.
I am not sure about this one this will either be very "flashy" as the checkmark will disappear on disable and then the menu resizes or we add a quite huge margin for all button on the right side. Example: vokoscreenNG-2023-11-02_13-43-42.mp4This also works for this corner case (groups): vokoscreenNG-2023-11-02_14-02-27.mp4 |
With an icon but without margin it would look like this: vokoscreenNG-2023-11-02_13-53-58.mp4And with additional margin on "un-pressed": vokoscreenNG-2023-11-02_13-55-03.mp4 |
Thanks for the examples @susnux! :) I think the variant with the checkmark and the additional marking of course (so it doesn’t jump) is the best one. The background color change wouldn’t pass contrast requirements unless we change it to primary-element background with white text – which we could also do, just like in Nextcloud Office or Text. |
@jancborchardt no this is fine, I tested that combination (the PR on server were we adjusted the colors so that common combinations work find (here it is primary-element-light + primary-element-light-text) I am fine with the icon, the only down side is it can not be used in the button group example (see video) |
We could do both. An icon and the background change. |
Thank you @susnux! My impression regarding contrasts on selected / pressed button: if there is no other indicator (like check icon) then contrast have to be 3:1 (focused <-> unfocused, focused <-> surrounding background) like it was here nextcloud/text#3860 Could we use another outline or background color? |
What is the suggested active state? Border does not work because it will be overridden by the focus state, as focus uses the border instead of outline. So only the fill color or icon is possible. |
Ok, we can move with a "checked" icon. But then we have to notify a screen reader that something happened (checked, unchecked) via |
This is already done by |
Adding aria-pressed to an element with a role of button turns the button into a toggle button. The aria-pressed attribute is only relevant for toggle buttons. not sure that |
Yes this is about toggle button, like toggle between full screen view and windowed. Or toggle left align etc. |
I've just asked myself because it is like a normal button inside a "normal" menu. Let's leave it like toggle button 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fine to me!
c0b04f1
to
d8701b7
Compare
So currently it looks like this: vokoscreenNG-2023-11-08_01-39-27.mp4 |
What should it be used instead of |
I think, this can be useful for Current usage
The most problematic part in my opinion - menu item with a radio behavior. Because there is no way to specify a group. My idea - allow a menu to have no more than one radio group (use Proposal
Alternative solution
|
d8701b7
to
5ff8f0e
Compare
@ShGKme I fully agree with your points and I think your proposal is the best way to implement this. Please feel free to review :) |
c91b8a3
to
cc6ce59
Compare
e09abbb
to
7836434
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks cool, seems to work and covers all the use-cases having good a11y, thanks!
Just some nitpicks/thoughts
36f1311
to
2c795b9
Compare
@ShGKme could you give this a try for the 8.5.0 release? |
/** | ||
* The buttons state if `type` is 'checkbox' or 'radio' (meaning if it is pressed / selected) | ||
* Either boolean for checkbox and toggle button behavior or `value` for radio behavior | ||
*/ | ||
modelValue: { | ||
type: [Boolean, String], | ||
default: null, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's said "if type
is 'checkbox' or 'radio'" but it also changes attributes on other types.
And I think it's worth mentioning that null
(the default value) in a specific case (in a menu with type checkbox) actually means mixed
, not false
.
Do we actually need this mixed
value? It is not supported by NcButton
, and there is no UI for this value. If feels a bit complicated to me...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added more documentation on this behavior
… to NcButton * Use trailing icon for pressed state Signed-off-by: Ferdinand Thiessen <[email protected]>
…elected button Signed-off-by: Ferdinand Thiessen <[email protected]>
…ked states * This introduces new props `modelValue`, `modelBehavior` and `radioValue` Signed-off-by: Ferdinand Thiessen <[email protected]>
…`NcButton` for inline actions Signed-off-by: Ferdinand Thiessen <[email protected]>
Signed-off-by: Ferdinand Thiessen <[email protected]>
e1816e4
to
00b1c74
Compare
☑️ Resolves
NcButton already allows a checked state so this introduces this for the NcActionButton.
In checked state the
aria-pressed
attribute will be added and a primary border will indicate it visually.🖼️ Screenshots
vokoscreenNG-2023-11-02_00-37-54.mp4
🏁 Checklist