Skip to content

feat: add isPressedWhenOpen prop to overlay trigger components#10296

Open
Arman-Luthra wants to merge 2 commits into
adobe:mainfrom
Arman-Luthra:feat/is-pressed-when-open
Open

feat: add isPressedWhenOpen prop to overlay trigger components#10296
Arman-Luthra wants to merge 2 commits into
adobe:mainfrom
Arman-Luthra:feat/is-pressed-when-open

Conversation

@Arman-Luthra

Copy link
Copy Markdown

closes #8339

summary

adds an isPressedWhenOpen prop (default true) to the react-aria-components trigger components that currently force isPressed on the trigger button while their overlay is open: DialogTrigger, MenuTrigger, Select, ComboBox, DatePicker, and DateRangePicker.

passing isPressedWhenOpen={false} keeps the trigger's press state tied to actual presses, so data-pressed clears 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 s2 DialogTrigger workaround keep working as before.

implementation

each of the six components passes isPressed: state.isOpen to either a PressResponder or ButtonContext. 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 DialogTrigger workaround (<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-expanded or the dialog/menu is in the document), and assert data-pressed is 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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Button remains in pressed state when opening a modal

1 participant