[fix] page menu, drag handle css (#1406)
This PR fixes the CSS for the page menu drag handle while editing. It also makes the page menu participate in the `useMenuIsOpen` API. ### Change Type - [x] `patch` — Bug Fix ### Test Plan 1. Select the draw tool 2. Open the page menu 3. Click on the canvas—there should be no dot! 4. Open the page menu 5. Click the edit icon 6. Hover the drag handle; the handle should look correct ### Release Notes - Fix styling in the page menu
This commit is contained in:
parent
6a7dc12162
commit
2a9ff82a70
2 changed files with 7 additions and 9 deletions
|
@ -3,6 +3,7 @@ import { TLPage, TLPageId } from '@tldraw/tlschema'
|
||||||
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'
|
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'
|
||||||
import { useValue } from 'signia-react'
|
import { useValue } from 'signia-react'
|
||||||
import { useBreakpoint } from '../../hooks/useBreakpoint'
|
import { useBreakpoint } from '../../hooks/useBreakpoint'
|
||||||
|
import { useMenuIsOpen } from '../../hooks/useMenuIsOpen'
|
||||||
import { useTranslation } from '../../hooks/useTranslation/useTranslation'
|
import { useTranslation } from '../../hooks/useTranslation/useTranslation'
|
||||||
import { Button } from '../primitives/Button'
|
import { Button } from '../primitives/Button'
|
||||||
import { Icon } from '../primitives/Icon'
|
import { Icon } from '../primitives/Icon'
|
||||||
|
@ -16,6 +17,10 @@ export const PageMenu = function PageMenu() {
|
||||||
const msg = useTranslation()
|
const msg = useTranslation()
|
||||||
const breakpoint = useBreakpoint()
|
const breakpoint = useBreakpoint()
|
||||||
|
|
||||||
|
const handleOpenChange = useCallback(() => setIsEditing(false), [])
|
||||||
|
|
||||||
|
const [isOpen, onOpenChange] = useMenuIsOpen('page-menu', handleOpenChange)
|
||||||
|
|
||||||
const ITEM_HEIGHT = breakpoint < 5 ? 36 : 40
|
const ITEM_HEIGHT = breakpoint < 5 ? 36 : 40
|
||||||
|
|
||||||
const rSortableContainer = useRef<HTMLDivElement>(null)
|
const rSortableContainer = useRef<HTMLDivElement>(null)
|
||||||
|
@ -41,13 +46,6 @@ export const PageMenu = function PageMenu() {
|
||||||
setIsEditing((s) => !s)
|
setIsEditing((s) => !s)
|
||||||
}, [isReadonlyMode])
|
}, [isReadonlyMode])
|
||||||
|
|
||||||
const [isOpen, setIsOpen] = useState(false)
|
|
||||||
|
|
||||||
const handleOpenChange = useCallback((isOpen: boolean) => {
|
|
||||||
setIsOpen(isOpen)
|
|
||||||
setIsEditing(false)
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
const rMutables = useRef({
|
const rMutables = useRef({
|
||||||
isPointing: false,
|
isPointing: false,
|
||||||
status: 'idle' as 'idle' | 'pointing' | 'dragging',
|
status: 'idle' as 'idle' | 'pointing' | 'dragging',
|
||||||
|
@ -238,7 +236,7 @@ export const PageMenu = function PageMenu() {
|
||||||
}, [app, msg, isReadonlyMode])
|
}, [app, msg, isReadonlyMode])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Popover id="page menu" onOpenChange={handleOpenChange} open={isOpen}>
|
<Popover id="page menu" onOpenChange={onOpenChange} open={isOpen}>
|
||||||
<PopoverTrigger>
|
<PopoverTrigger>
|
||||||
<Button
|
<Button
|
||||||
className="tlui-page-menu__trigger tlui-menu__trigger"
|
className="tlui-page-menu__trigger tlui-menu__trigger"
|
||||||
|
|
|
@ -1870,7 +1870,7 @@
|
||||||
.tlui-page_menu__item__sortable__handle {
|
.tlui-page_menu__item__sortable__handle {
|
||||||
touch-action: none;
|
touch-action: none;
|
||||||
width: 32px;
|
width: 32px;
|
||||||
height: 100%;
|
height: 40px;
|
||||||
cursor: grab;
|
cursor: grab;
|
||||||
color: var(--color-text-3);
|
color: var(--color-text-3);
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
|
|
Loading…
Reference in a new issue