fix(RAC): clear pressed state on DialogTrigger when dialog opens#10135
Open
EduardF1 wants to merge 2 commits into
Open
fix(RAC): clear pressed state on DialogTrigger when dialog opens#10135EduardF1 wants to merge 2 commits into
EduardF1 wants to merge 2 commits into
Conversation
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>
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.
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.