feat: allow customizing behavior of pressed state #8971
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #8339
Several components like Dialog and Select set
data-pressed="true"on the trigger while the corresponding overlay is open, which is often not desired for styling. As outlined in the issue, a new property has been added to these components to prevent this behavior. The default value istrue, so the behavior remains unchanged by default.Naming: A few names for the property were suggested in the issue. I used
isPressedWhenOpenon trigger components (DialogTrigger, MenuTrigger), andisTriggerPressedWhenOpenfor other components to make it clear that the property affects the trigger.I think it's easier to understand than
consideredPressedWhenOpen. AndpersistPressStateWhenOpendoesn't feel right for me for components likeMenuwhich open the overlay on press start and therefore never havedata-pressed=truewith the new behavior.Storybook: I added a new control to the corresponding RAC stories which already used Story controls. Most of them don't and I didn't add a separate Story for it. If I should add them, let me know.
Spectrum: I also updated the S2 components, I hope that's okay.
DialogTriggerPropsto fully extend the RACDialogTriggerProps(which was the case before). Is that ok?isPressed={false}) are removed.TabsPickercomponent.✅ Pull Request Checklist:
📝 Test Instructions:
yarn startdata-pressed="true"isTriggerPressedWhenOpentofalsedata-pressedis not set anymore🧢 Your Project: