Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(desk): use correct dialog positioning at smaller breakpoints #4894

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/sanity/src/desk/components/deskTool/DeskTool.tsx
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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