From 72b80985453522b114693706f9f6c8c6047b7b6f Mon Sep 17 00:00:00 2001 From: Devon Govett Date: Tue, 20 Aug 2024 14:50:48 -0700 Subject: [PATCH] Fix buttons in S2 dialogs stuck in hover state (#6916) Co-authored-by: Daniel Lu --- packages/@react-spectrum/s2/src/Dialog.tsx | 209 +++++++++++---------- 1 file changed, 105 insertions(+), 104 deletions(-) diff --git a/packages/@react-spectrum/s2/src/Dialog.tsx b/packages/@react-spectrum/s2/src/Dialog.tsx index 5f0f206b304..2e61f88e184 100644 --- a/packages/@react-spectrum/s2/src/Dialog.tsx +++ b/packages/@react-spectrum/s2/src/Dialog.tsx @@ -10,7 +10,7 @@ * governing permissions and limitations under the License. */ -import {PopoverProps as AriaPopoverProps, composeRenderProps, Provider, Dialog as RACDialog, DialogProps as RACDialogProps} from 'react-aria-components'; +import {PopoverProps as AriaPopoverProps, composeRenderProps, OverlayTriggerStateContext, Provider, Dialog as RACDialog, DialogProps as RACDialogProps} from 'react-aria-components'; import {ButtonGroupContext} from './ButtonGroup'; import {CloseButton} from './CloseButton'; import {ContentContext, FooterContext, HeaderContext, HeadingContext, ImageContext} from './Content'; @@ -187,125 +187,126 @@ function DialogInner(props: DialogProps & DialogContextValue & {dialogRef: RefOb ref={props.dialogRef} style={props.UNSAFE_style} className={(props.UNSAFE_className || '') + dialogInner}> - {composeRenderProps(props.children, (children, {close}) => - // Render the children multiple times inside the wrappers we need to implement the layout. - // Each instance hides certain children so that they are all rendered in the correct locations. - (<> - {/* Hero image */} - - {children} - - {/* Top header: heading, header, dismiss button, and button group (in fullscreen dialogs). */} + {composeRenderProps(props.children, (children, {close}) => ( + // Render the children multiple times inside the wrappers we need to implement the layout. + // Each instance hides certain children so that they are all rendered in the correct locations. + // Reset OverlayTriggerStateContext so the buttons inside the dialog don't retain their hover state. + + {/* Hero image */} + + {children} + + {/* Top header: heading, header, dismiss button, and button group (in fullscreen dialogs). */} +
-
- - {children} - -
- {props.isDismissable && - - } -
- {/* Main content */} - - {children} - - {/* Footer and button group */} -
{children}
- ) - )} + {props.isDismissable && + + } +
+ {/* Main content */} + + {children} + + {/* Footer and button group */} +
+ + {children} + +
+
+ ))} ); }