Skip to content

Commit

Permalink
fix(desk): use correct dialog positioning at smaller breakpoints (#4894)
Browse files Browse the repository at this point in the history
Co-authored-by: Nina Andal Aarvik <nina@sanity.io>
  • Loading branch information
robinpyon and ninaandal committed Sep 8, 2023
1 parent 7e9e48f commit e62906f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
7 changes: 5 additions & 2 deletions packages/sanity/src/desk/components/deskTool/DeskTool.tsx
@@ -1,4 +1,4 @@
import {PortalProvider, useToast} from '@sanity/ui'
import {PortalProvider, useTheme, useToast} from '@sanity/ui'
import React, {memo, Fragment, useState, useEffect, useCallback} from 'react'
import styled from 'styled-components'
import isHotkey from 'is-hotkey'
Expand Down Expand Up @@ -38,6 +38,9 @@ export const DeskTool = memo(function DeskTool({onPaneChange}: DeskToolProps) {
const isResolvingIntent = useRouterState(
useCallback((routerState) => typeof routerState.intent === 'string', []),
)
const {
sanity: {media},
} = useTheme()

const [portalElement, setPortalElement] = useState<HTMLDivElement | null>(null)

Expand Down Expand Up @@ -84,7 +87,7 @@ export const DeskTool = memo(function DeskTool({onPaneChange}: DeskToolProps) {
<StyledPaneLayout
flex={1}
height={layoutCollapsed ? undefined : 'fill'}
minWidth={512}
minWidth={media[1]}
onCollapse={handleRootCollapse}
onExpand={handleRootExpand}
>
Expand Down
Expand Up @@ -14,6 +14,7 @@ import {
Stack,
Text,
TextInput,
useTheme,
} from '@sanity/ui'
import {useAction} from '@sanity/ui-workshop'
import React, {useCallback, useState} from 'react'
Expand Down Expand Up @@ -60,6 +61,10 @@ export default function ChangeConnectorsStory() {
const handleLayoutCollapse = useAction('PaneLayout.onCollapse')
const handleLayoutExpand = useAction('PaneLayout.onExpand')

const {
sanity: {media},
} = useTheme()

return (
<LayerProvider>
<Card height="fill" tone="transparent">
Expand All @@ -72,7 +77,7 @@ export default function ChangeConnectorsStory() {
>
<PaneLayout
height="fill"
minWidth={512}
minWidth={media[1]}
onCollapse={handleLayoutCollapse}
onExpand={handleLayoutExpand}
>
Expand Down
@@ -1,4 +1,4 @@
import {Flex, ToastProvider, PortalProvider} from '@sanity/ui'
import {Flex, ToastProvider, PortalProvider, useTheme} from '@sanity/ui'
import React, {useState, useCallback} from 'react'
import {useBoolean} from '@sanity/ui-workshop'
import {PaneLayout} from '../../PaneLayout'
Expand Down Expand Up @@ -50,11 +50,15 @@ function DeskTool(props: {
}) {
const {collapsed, onCollapse, onExpand, path, setPath} = props

const {
sanity: {media},
} = useTheme()

return (
<PaneLayout
flex={1}
height={collapsed ? undefined : 'fill'}
minWidth={512}
minWidth={media[1]}
onCollapse={onCollapse}
onExpand={onExpand}
>
Expand Down
3 changes: 2 additions & 1 deletion packages/sanity/src/desk/panes/document/DocumentPane.tsx
Expand Up @@ -46,7 +46,8 @@ import {
type DocumentPaneOptions = DocumentPaneNode['options']

const DIALOG_PROVIDER_POSITION: DialogProviderProps['position'] = [
// We use the `position: fixed` for dialogs on narrow screens (< 512px).
// We use the `position: fixed` for dialogs on narrower screens (first two media breakpoints).
'fixed',
'fixed',
// And we use the `position: absolute` strategy (within panes) on wide screens.
'absolute',
Expand Down

2 comments on commit e62906f

@vercel
Copy link

@vercel vercel bot commented on e62906f Sep 8, 2023

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:

performance-studio – ./

performance-studio.sanity.build
performance-studio-git-next.sanity.build

@vercel
Copy link

@vercel vercel bot commented on e62906f Sep 8, 2023

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.sanity.build
test-studio-git-next.sanity.build

Please sign in to comment.