Skip to content

fix(RAC): clear pressed state on DialogTrigger when dialog opens#10135

Open
EduardF1 wants to merge 2 commits into
adobe:mainfrom
EduardF1:fix/dialog-trigger-button-pressed-state
Open

fix(RAC): clear pressed state on DialogTrigger when dialog opens#10135
EduardF1 wants to merge 2 commits into
adobe:mainfrom
EduardF1:fix/dialog-trigger-button-pressed-state

Conversation

@EduardF1
Copy link
Copy Markdown

Summary

Fixes #8339

When a modal dialog is opened via \DialogTrigger, the trigger button remains visually stuck in a 'pressed' state because \isPressed\ was bound to \state.isOpen. This causes the press animation to never complete, giving the button the appearance of a frozen press state after the dialog opens.

Root cause

In \packages/react-aria-components/src/Dialog.tsx, the \PressResponder\ wrapping the trigger child had:

\\ sx
<PressResponder {...triggerProps} ref={buttonRef} isPressed={state.isOpen}>
\\

This means once the dialog opens (\state.isOpen === true), the trigger button's press state is locked to \ rue, regardless of whether the user has actually released the pointer.

Fix

Set \isPressed={false}\ unconditionally in \DialogTrigger:

\\ sx
<PressResponder {...triggerProps} ref={buttonRef} isPressed={false}>
\\

This matches the behavior already implemented in **Spectrum 2's \DialogTrigger**, which wraps \AriaDialogTrigger\ with a \PressResponder isPressed={false}\ override specifically to address this issue:

https://github.com/adobe/react-spectrum/blob/main/packages/%40react-spectrum/s2/src/DialogTrigger.tsx#L29-L37

For modal dialogs, the trigger button should return to its normal unpressed state once the dialog is open — the dialog itself provides the visual context that an action was taken.

When a modal dialog is opened via DialogTrigger, the trigger button
remains visually stuck in a 'pressed' state because isPressed was set
to state.isOpen. This causes the press animation to never complete,
giving the appearance of a frozen press state on the button.

This fix sets isPressed to false unconditionally in DialogTrigger,
matching the behavior already implemented in Spectrum 2's DialogTrigger
which wraps PressResponder with isPressed={false} as a workaround.

For modal dialogs (which open an overlay above the page), the trigger
button should return to its normal state once the dialog is open — the
dialog itself provides the visual context that an action was taken.

Fixes adobe#8339

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
With isPressed={false} in PressResponder, the trigger button no longer
reflects the dialog open state via data-pressed. Update the test to
match the new intentional behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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