-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
ToggleGroupControl: support disabled
options
#63450
Changes from all commits
c01f777
9546243
ceebf66
a1cf315
ea67533
62959f0
1d71066
8515e58
0ee013e
8172ca6
fe854cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,9 @@ function ToggleGroupControlOptionBase( | |
false | ||
>, | ||
// the element's id is generated internally | ||
'id' | ||
| 'id' | ||
// due to how the component works, only the `disabled` prop should be used | ||
| 'aria-disabled' | ||
Comment on lines
+56
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it makes sense to have the options There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually thought this was one of the cases where we always want the option to be focusable when disabled, similar to ToolbarButton (#63102) or tabs in a tablist. It's also a composite widget where there will be a limited number of options, and the number of tab stops it potentially adds to the tab sequence is either zero or negligible. Implementing that in the radio case for ToggleGroupControl would require some additional design work though 🤔 But at least Ariakit supports the behavior nicely (StackBlitz demo). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yep. Currently, since
Yup. We'll probably need to add the custom logic when rendering individual |
||
>, | ||
forwardedRef: ForwardedRef< any > | ||
) { | ||
|
@@ -82,6 +84,7 @@ function ToggleGroupControlOptionBase( | |
children, | ||
showTooltip = false, | ||
onFocus: onFocusProp, | ||
disabled, | ||
...otherButtonProps | ||
} = buttonProps; | ||
|
||
|
@@ -130,6 +133,7 @@ function ToggleGroupControlOptionBase( | |
{ isDeselectable ? ( | ||
<button | ||
{ ...commonProps } | ||
disabled={ disabled } | ||
onFocus={ onFocusProp } | ||
aria-pressed={ isPressed } | ||
type="button" | ||
|
@@ -139,6 +143,7 @@ function ToggleGroupControlOptionBase( | |
</button> | ||
) : ( | ||
<Ariakit.Radio | ||
disabled={ disabled } | ||
render={ | ||
<button | ||
type="button" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,11 @@ export const buttonView = ( { | |
border: 0; | ||
} | ||
|
||
&[disabled] { | ||
opacity: 0.4; | ||
cursor: default; | ||
Comment on lines
+68
to
+69
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have more and more of these disabled styles that do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, although this PR is not the right place for it. We should probably assess the current state of shared config in the package, and decide next steps. For example, some variables come from the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Definitely should be a separate PR 👍 |
||
} | ||
|
||
&:active { | ||
background: ${ CONFIG.toggleGroupControlBackgroundColor }; | ||
} | ||
|
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.
@ramonjd just making sure you're ok with those food options
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.
Sorry, I was away last week.
I would have preferred risotto instead of just "rice", but I appreciate you asking. 😆
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.
Ah, good point. Feel free to open a PR