Skip to content

Commit

Permalink
fix(field): fix z-index issues of tooltip and revert dialog (#2449)
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuslundgard committed Apr 28, 2021
1 parent a7413ac commit ba32ea1
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 97 deletions.
2 changes: 1 addition & 1 deletion packages/@sanity/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"@sanity/structure": "2.9.1",
"@sanity/transaction-collator": "2.7.4",
"@sanity/types": "2.9.1",
"@sanity/ui": "^0.33.18",
"@sanity/ui": "^0.33.19",
"@sanity/util": "2.9.1",
"@sanity/validation": "2.9.1",
"boundless-arrow-key-navigation": "^1.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/@sanity/default-layout/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@sanity/client": "2.8.0",
"@sanity/generate-help-url": "2.2.6",
"@sanity/types": "2.9.1",
"@sanity/ui": "^0.33.18",
"@sanity/ui": "^0.33.19",
"@sanity/util": "2.9.1",
"classnames": "^2.2.5",
"is-hotkey": "^0.1.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/@sanity/desk-tool/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@sanity/react-hooks": "2.9.1",
"@sanity/structure": "2.9.1",
"@sanity/types": "2.9.1",
"@sanity/ui": "^0.33.18",
"@sanity/ui": "^0.33.19",
"@sanity/util": "2.9.1",
"@sanity/uuid": "^3.0.1",
"boundless-arrow-key-navigation": "^1.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/@sanity/field/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@sanity/diff": "2.7.4",
"@sanity/react-hooks": "2.9.1",
"@sanity/types": "2.9.1",
"@sanity/ui": "^0.33.18",
"@sanity/ui": "^0.33.19",
"@sanity/util": "2.9.1",
"date-fns": "^2.16.1",
"sanity-diff-patch": "^1.0.9",
Expand Down
48 changes: 25 additions & 23 deletions packages/@sanity/field/src/diff/components/ChangeList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,31 +104,33 @@ export function ChangeList({diff, fields, schemaType}: Props): React.ReactElemen
</Button>
</div>
)}

{confirmRevertAllOpen && (
<PopoverDialog
actions={[
{
color: 'danger',
action: revertAllChanges,
title: 'Revert all',
},
{
kind: 'simple',
action: closeRevertAllChangesConfirmDialog,
title: 'Cancel',
},
]}
onAction={handleConfirmDialogAction}
onClickOutside={closeRevertAllChangesConfirmDialog}
referenceElement={revertAllContainerElement}
size="small"
>
Are you sure you want to revert all {changes.length} changes?
</PopoverDialog>
)}
</div>
)}

{confirmRevertAllOpen && (
<LegacyLayerProvider zOffset="paneFooter">
<PopoverDialog
actions={[
{
color: 'danger',
action: revertAllChanges,
title: 'Revert all',
},
{
kind: 'simple',
action: closeRevertAllChangesConfirmDialog,
title: 'Cancel',
},
]}
onAction={handleConfirmDialogAction}
onClickOutside={closeRevertAllChangesConfirmDialog}
referenceElement={revertAllContainerElement}
size="small"
>
Are you sure you want to revert all {changes.length} changes?
</PopoverDialog>
</LegacyLayerProvider>
)}
</div>
)
}
Expand Down
20 changes: 11 additions & 9 deletions packages/@sanity/field/src/diff/components/DiffTooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {UserAvatar} from '@sanity/base/components'
import {LegacyLayerProvider, UserAvatar} from '@sanity/base/components'
import {useUser, useTimeAgo} from '@sanity/base/hooks'
import {Path} from '@sanity/types'
import React from 'react'
Expand Down Expand Up @@ -52,14 +52,16 @@ function DiffTooltipWithAnnotation(props: DiffTooltipWithAnnotationsProps) {
)

return (
<Tooltip
content={content}
placement={placement}
portal
allowedAutoPlacements={['top', 'bottom']}
>
{children}
</Tooltip>
<LegacyLayerProvider zOffset="paneFooter">
<Tooltip
content={content}
placement={placement}
portal
allowedAutoPlacements={['top', 'bottom']}
>
{children}
</Tooltip>
</LegacyLayerProvider>
)
}

Expand Down
70 changes: 35 additions & 35 deletions packages/@sanity/field/src/diff/components/FieldChange.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,44 +80,44 @@ export function FieldChange({change}: {change: FieldChangeNode}) {
)}

{isComparingCurrent && (
<>
<div className={styles.revertChangesButtonContainer}>
<RevertChangesButton
onClick={handleRevertChangesConfirm}
onMouseEnter={handleRevertButtonMouseEnter}
onMouseLeave={handleRevertButtonMouseLeave}
ref={setRevertButtonElement}
selected={confirmRevertOpen}
/>
</div>

{confirmRevertOpen && (
<PopoverDialog
actions={[
{
color: 'danger',
action: handleRevertChanges,
title: 'Revert change',
},
{
kind: 'simple',
action: closeRevertChangesConfirmDialog,
title: 'Cancel',
},
]}
onAction={handleConfirmDialogAction}
onClickOutside={closeRevertChangesConfirmDialog}
portal
referenceElement={revertButtonElement}
size="small"
>
Are you sure you want to revert the changes?
</PopoverDialog>
)}
</>
<div className={styles.revertChangesButtonContainer}>
<RevertChangesButton
onClick={handleRevertChangesConfirm}
onMouseEnter={handleRevertButtonMouseEnter}
onMouseLeave={handleRevertButtonMouseLeave}
ref={setRevertButtonElement}
selected={confirmRevertOpen}
/>
</div>
)}
</DiffInspectWrapper>
</FieldWrapper>

{confirmRevertOpen && (
<LegacyLayerProvider zOffset="paneFooter">
<PopoverDialog
actions={[
{
color: 'danger',
action: handleRevertChanges,
title: 'Revert change',
},
{
kind: 'simple',
action: closeRevertChangesConfirmDialog,
title: 'Cancel',
},
]}
onAction={handleConfirmDialogAction}
onClickOutside={closeRevertChangesConfirmDialog}
portal
referenceElement={revertButtonElement}
size="small"
>
Are you sure you want to revert the changes?
</PopoverDialog>
</LegacyLayerProvider>
)}
</div>
)
}
49 changes: 26 additions & 23 deletions packages/@sanity/field/src/diff/components/GroupChange.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {DialogAction} from '@sanity/base/__legacy/@sanity/components'
import {LegacyLayerProvider} from '@sanity/base/components'
import classNames from 'classnames'
import {useDocumentOperation} from '@sanity/react-hooks'
import PopoverDialog from 'part:@sanity/components/dialogs/popover'
Expand Down Expand Up @@ -77,29 +78,6 @@ export function GroupChange({change: group}: {change: GroupChangeNode}): React.R
selected={confirmRevertOpen}
/>
</div>

{confirmRevertOpen && (
<PopoverDialog
actions={[
{
color: 'danger',
action: handleRevertChanges,
title: 'Revert change',
},
{
kind: 'simple',
action: closeRevertChangesConfirmDialog,
title: 'Cancel',
},
]}
onAction={handleConfirmDialogAction}
// portal
referenceElement={revertButtonElement}
size="small"
>
Are you sure you want to revert the changes?
</PopoverDialog>
)}
</>
)}
</div>
Expand All @@ -117,6 +95,31 @@ export function GroupChange({change: group}: {change: GroupChangeNode}): React.R
{content}
</FieldWrapper>
)}

{confirmRevertOpen && (
<LegacyLayerProvider zOffset="paneFooter">
<PopoverDialog
actions={[
{
color: 'danger',
action: handleRevertChanges,
title: 'Revert change',
},
{
kind: 'simple',
action: closeRevertChangesConfirmDialog,
title: 'Cancel',
},
]}
onAction={handleConfirmDialogAction}
// portal
referenceElement={revertButtonElement}
size="small"
>
Are you sure you want to revert the changes?
</PopoverDialog>
</LegacyLayerProvider>
)}
</div>
)
}
2 changes: 1 addition & 1 deletion packages/@sanity/form-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@sanity/mutator": "2.2.6",
"@sanity/portable-text-editor": "0.1.25",
"@sanity/types": "2.9.1",
"@sanity/ui": "^0.33.18",
"@sanity/ui": "^0.33.19",
"@sanity/util": "2.9.1",
"@sanity/uuid": "^3.0.1",
"attr-accept": "^1.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/@sanity/storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"dependencies": {
"@sanity/base": "2.9.1",
"@sanity/server": "2.9.1",
"@sanity/ui": "^0.33.18",
"@sanity/ui": "^0.33.19",
"@sanity/webpack-integration": "2.9.1",
"@storybook/addon-actions": "^3.4.11",
"@storybook/addon-knobs": "^3.2.8",
Expand Down
2 changes: 1 addition & 1 deletion packages/@sanity/vision/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
],
"dependencies": {
"@sanity/icons": "^1.0.5",
"@sanity/ui": "^0.33.18",
"@sanity/ui": "^0.33.19",
"classnames": "^2.2.5",
"codemirror": "^5.47.0",
"moment": "^2.19.1",
Expand Down

2 comments on commit ba32ea1

@vercel
Copy link

@vercel vercel bot commented on ba32ea1 Apr 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

test-studio – ./

test-studio-git-next.sanity.build
test-studio.sanity.build

@vercel
Copy link

@vercel vercel bot commented on ba32ea1 Apr 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

perf-studio – ./

perf-studio.sanity.build
perf-studio-git-next.sanity.build

Please sign in to comment.