feat: add isPressedWhenOpen prop to overlay trigger components#10296
Open
Arman-Luthra wants to merge 2 commits into
Open
feat: add isPressedWhenOpen prop to overlay trigger components#10296Arman-Luthra wants to merge 2 commits into
Arman-Luthra wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
summary
adds an
isPressedWhenOpenprop (defaulttrue) to the react-aria-components trigger components that currently forceisPressedon the trigger button while their overlay is open:DialogTrigger,MenuTrigger,Select,ComboBox,DatePicker, andDateRangePicker.passing
isPressedWhenOpen={false}keeps the trigger's press state tied to actual presses, sodata-pressedclears on release instead of persisting for as long as the overlay is open. this is the prop suggested in #8339 (comment) (name taken from the list there; happy to rename if the team prefers another option). the default is unchanged, so existing consumers and the s2DialogTriggerworkaround keep working as before.implementation
each of the six components passes
isPressed: state.isOpento either aPressResponderorButtonContext. the change gates that value:isPressed: (props.isPressedWhenOpen ?? true) && state.isOpen. the prop is documented with jsdoc on each props interface so it lands in the generated prop tables.a follow-up could migrate the s2
DialogTriggerworkaround (<PressResponder isPressed={false}>) to this prop; left out of this pr to keep it scoped to the rac api.tests
one test per component: open the overlay via the existing test-util or click pattern, assert the overlay is open (
aria-expandedor the dialog/menu is in the document), and assertdata-pressedis absent. all six fail without the implementation. existing tests covering the default pressed-while-open behavior are untouched and still pass (228 tests across the six files).