Skip to content

Commit

Permalink
fix(ui-drawer-layout,ui-tray): fix multiple mounting during transition
Browse files Browse the repository at this point in the history
Closes: INSTUI-3887
  • Loading branch information
HerrTopi committed Oct 12, 2023
1 parent 9f3e0f5 commit 8c9e2e5
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 43 deletions.
46 changes: 22 additions & 24 deletions packages/ui-drawer-layout/src/DrawerLayout/DrawerTray/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -252,30 +252,28 @@ class DrawerTray extends Component<
ref={this.handleContentRef}
css={trayStyles}
>
{this.state.transitioning ? (
this.renderContent()
) : (
<Dialog
open
role={shouldOverlayTray ? 'dialog' : 'region'}
label={label}
shouldReturnFocus={shouldReturnFocus}
shouldContainFocus={shouldContainFocus && shouldOverlayTray}
shouldCloseOnDocumentClick={
shouldCloseOnDocumentClick && shouldOverlayTray
}
shouldCloseOnEscape={
shouldCloseOnEscape && shouldOverlayTray
}
defaultFocusElement={defaultFocusElement}
liveRegion={liveRegion}
onDismiss={onDismiss}
as="div"
css={this.props.styles?.drawerTrayContent}
>
{this.renderContent()}
</Dialog>
)}
<Dialog
open
role={shouldOverlayTray ? 'dialog' : 'region'}
label={label}
shouldReturnFocus={shouldReturnFocus}
shouldContainFocus={
!this.state.transitioning &&
shouldContainFocus &&
shouldOverlayTray
}
shouldCloseOnDocumentClick={
shouldCloseOnDocumentClick && shouldOverlayTray
}
shouldCloseOnEscape={shouldCloseOnEscape && shouldOverlayTray}
defaultFocusElement={defaultFocusElement}
liveRegion={liveRegion}
onDismiss={onDismiss}
as="div"
css={this.props.styles?.drawerTrayContent}
>
{this.renderContent()}
</Dialog>
</div>
</Transition>
)
Expand Down
36 changes: 17 additions & 19 deletions packages/ui-tray/src/Tray/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,25 +201,23 @@ class Tray extends Component<TrayProps> {
css={this.props.styles?.tray}
ref={contentRef}
>
{this.state.transitioning ? (
children
) : (
<Dialog
as="div"
label={label}
defaultFocusElement={defaultFocusElement}
open
shouldContainFocus={shouldContainFocus}
shouldReturnFocus={shouldReturnFocus}
shouldCloseOnDocumentClick={shouldCloseOnDocumentClick}
shouldCloseOnEscape
liveRegion={liveRegion}
onDismiss={onDismiss}
role={role}
>
<div css={this.props.styles?.content}>{children}</div>
</Dialog>
)}
<Dialog
as="div"
label={label}
defaultFocusElement={defaultFocusElement}
open
shouldContainFocus={
!this.state.transitioning && shouldContainFocus
}
shouldReturnFocus={shouldReturnFocus}
shouldCloseOnDocumentClick={shouldCloseOnDocumentClick}
shouldCloseOnEscape
liveRegion={liveRegion}
onDismiss={onDismiss}
role={role}
>
<div css={this.props.styles?.content}>{children}</div>
</Dialog>
</span>
</Transition>
)}
Expand Down

0 comments on commit 8c9e2e5

Please sign in to comment.