Skip to content

Commit 1284e57

Browse files
committed
Fix setting menu portal styles
1 parent 3be7d9c commit 1284e57

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

packages/query-devtools/src/Devtools.tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ const ContentView: Component<DevtoolsPanelProps> = (props) => {
463463
setupQueryCacheSubscription()
464464
setupMutationCacheSubscription()
465465

466+
let containerRef!: HTMLDivElement
466467
const theme = useTheme()
467468
const styles = createMemo(() => {
468469
return theme() === 'dark' ? darkStyles : lightStyles
@@ -572,6 +573,13 @@ const ContentView: Component<DevtoolsPanelProps> = (props) => {
572573
props.setLocalStore('position', pos)
573574
}
574575

576+
// Sets the Font Size variable on portal menu elements since they will be outside
577+
// the main panel container
578+
const setComputedVariables = (el: HTMLDivElement) => {
579+
const computedStyle = getComputedStyle(containerRef)
580+
const variable = computedStyle.getPropertyValue('--tsqd-font-size')
581+
el.style.setProperty('--tsqd-font-size', variable)
582+
}
575583
return (
576584
<>
577585
<div
@@ -587,6 +595,7 @@ const ContentView: Component<DevtoolsPanelProps> = (props) => {
587595
`,
588596
'tsqd-queries-container',
589597
)}
598+
ref={containerRef}
590599
>
591600
<div class={cx(styles().row, 'tsqd-header')}>
592601
<div class={styles().logoAndToggleContainer}>
@@ -815,7 +824,9 @@ const ContentView: Component<DevtoolsPanelProps> = (props) => {
815824
>
816825
<Settings />
817826
</DropdownMenu.Trigger>
818-
<DropdownMenu.Portal>
827+
<DropdownMenu.Portal
828+
ref={(el) => setComputedVariables(el as HTMLDivElement)}
829+
>
819830
<DropdownMenu.Content
820831
class={cx(styles().settingsMenu, 'tsqd-settings-menu')}
821832
>
@@ -838,7 +849,9 @@ const ContentView: Component<DevtoolsPanelProps> = (props) => {
838849
<span>Position</span>
839850
<ChevronDown />
840851
</DropdownMenu.SubTrigger>
841-
<DropdownMenu.Portal>
852+
<DropdownMenu.Portal
853+
ref={(el) => setComputedVariables(el as HTMLDivElement)}
854+
>
842855
<DropdownMenu.SubContent
843856
class={cx(
844857
styles().settingsMenu,
@@ -915,7 +928,9 @@ const ContentView: Component<DevtoolsPanelProps> = (props) => {
915928
<span>Theme</span>
916929
<ChevronDown />
917930
</DropdownMenu.SubTrigger>
918-
<DropdownMenu.Portal>
931+
<DropdownMenu.Portal
932+
ref={(el) => setComputedVariables(el as HTMLDivElement)}
933+
>
919934
<DropdownMenu.SubContent
920935
class={cx(
921936
styles().settingsMenu,

0 commit comments

Comments
 (0)