Skip to content

Commit

Permalink
fix(rac): Aria Modal issues when it is dismissible
Browse files Browse the repository at this point in the history
Change-Id: Ia55a1e0b59ff05f076b763df29dd1ffd72ad31a4
GitOrigin-RevId: 7a6a14179fa349d235cf70df57db5e4e4b377fe9
  • Loading branch information
sarahsga authored and actions-user committed Oct 29, 2024
1 parent 22fa431 commit 532f21f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions plasmicpkgs/react-aria/src/registerModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const BaseModal = forwardRef<BaseModalActions, BaseModalProps>(
isOpen,
resetClassName,
setControlContextData,
isDismissable,
...rest
} = props;

Expand All @@ -57,6 +58,15 @@ export const BaseModal = forwardRef<BaseModalActions, BaseModalProps>(
const isStandalone = !contextProps;
const mergedProps = mergeProps(contextProps, rest, {
isOpen: isStandalone ? isSelected || isOpen : contextProps.isOpen,
/**
* isDismissable on canvas (non-interactive mode) causes the following two issues:
* 1. Clicking anywhere inside the modal dismisses it
* 2. If the modal is auto-opened due to selection in outline tab, the modal stays open despite issue #1, but the text elements inside the modal are no longer selectable, and therefore the text or headings inside the modal are not editable.
*
* To fix the above issue, we set an interim isDismissable state to false while the modal is auto-open (`isSelected` is true).
* Also note that `isSelected` can only be true in canvas (non-interactive mode), so we can safely (temporarily) set `isDismissable` to false in this case, because it only matters in interactive mode.
* */
isDismissable: isSelected ? false : isDismissable,
});

setControlContextData?.({
Expand Down

0 comments on commit 532f21f

Please sign in to comment.