fix(ui): keep drag handles free of pointer focus outlines

This commit is contained in:
Codex
2026-11-17 01:55:47 +03:00
parent 8539a211ed
commit 533723883d
13 changed files with 72 additions and 19 deletions
+2 -2
View File
@@ -11,8 +11,8 @@
},
"dependencies": {
"@nodedc/page-patterns": "0.1.0",
"@nodedc/ui-core": "0.7.1",
"@nodedc/ui-react": "0.7.3",
"@nodedc/ui-core": "0.7.2",
"@nodedc/ui-react": "0.7.4",
"cesium": "1.147.0",
"react": "^19.1.0",
"react-dom": "^19.1.0"
+1 -1
View File
@@ -8,7 +8,7 @@ export function EditorDockExample({inWindow=false}:{inWindow?:boolean}){
return <>{!inWindow&&<><Button onClick={()=>setModal(true)}>Сцена в модальном окне</Button><Window open={modal} title="Просмотр сцены" onClose={()=>setModal(false)}><EditorDockExample inWindow/></Window></>}<Button onClick={()=>{setPurpose('edit');setOpen({objects:true,materials:true});setEditing(true);}}>Открыть редактор сцены</Button><Button onClick={()=>{setPurpose('view');setEditing(true);}}>Отдельное окно просмотра</Button><div style={{height:480}}>
<EditorWorkspace editing={editing} purpose={purpose} title={purpose==='view'?'Просмотр сцены':'Редактор сцены'} subtitle="Общая оконная система" onBack={()=>setEditing(false)} headerActions={purpose==='view'?<Button onClick={()=>setOpen({objects:true,materials:true})}>Показать инструменты</Button>:undefined}>
<EditorDockLayout value={layout} onChange={setLayout} enabled={editing} primary={<div style={{display:'grid',height:'100%',placeContent:'center'}}><Description>Закреплённая сцена · откреплённые инструменты используют scene Glass V4</Description><Button onClick={()=>setOpen({objects:true,materials:true})}>Показать инструменты</Button></div>}
tools={[{id:'objects',title:'Объекты',label:'Объекты',open:open.objects,onClose:()=>setOpen(v=>({...v,objects:false})),content:<Description>Сцена → Модель → Детали</Description>},
tools={[{id:'objects',title:'Объекты',label:'Объекты',open:open.objects,onClose:()=>setOpen(v=>({...v,objects:false})),content:<Description>Сцена → Модель → Детали. Захват шапки — без рамки; Tab и стрелки — клавиатурное управление.</Description>},
{id:'materials',title:'Материалы',label:'Материалы',minimumSize:{width:380,height:280},footer:<Button width="full" onClick={()=>setColor('#292929')}>Сбросить настройки</Button>,open:open.materials,onClose:()=>setOpen(v=>({...v,materials:false})),content:<Inspector sections={[{id:"color",label:"Цвет без обводки и пипетка",content:<ControlRow label="Цвет"><ColorField label="Цвет материала" value={color} onChange={setColor}/></ControlRow>}]} defaultOpen={["color"]} header={<Description>Минимум 380 × 280. Пипетка берёт цвет с экрана после нажатия; Escape отменяет выбор. Нижняя кнопка не прокручивается.</Description>}/>}]}/>
</EditorWorkspace>
</div></>;
+4
View File
@@ -171,3 +171,7 @@ Tool minimumSize governs floating and docked geometry alike, including restored
The primary scene owns an isolated stacking context so its toolbars stay behind floating tools. A tool outer shell clips without scrolling; only its body scrolls, keeping header/footer fixed even when a field receives focus.
ColorField spectrum has no decorative perimeter stroke; retain its visible sampling marker and keyboard focus. UserProfileMenu variant=header owns its HeaderProfile surface; consumers must not wrap it in another HeaderProfile.
## Focus of movable headers
Window, WorkspaceWindow and EditorDockLayout share the same drag-header focus contract. A pointer grab never inherits a keyboard focus ring or filled header from the previously focused input. Headers have no perimeter outline in any theme; keyboard focus uses the canonical contrasting surface. Pointer capture, focus ownership, Arrow/Shift+Arrow movement/resizing, Enter/Space docking and Escape cancellation remain unchanged. Check both direct grabbing and input → Tab → grabbing, in docked/floating and fullscreen contexts.
+6 -6
View File
@@ -28,8 +28,8 @@
"version": "0.7.0",
"dependencies": {
"@nodedc/page-patterns": "0.1.0",
"@nodedc/ui-core": "0.7.1",
"@nodedc/ui-react": "0.7.3",
"@nodedc/ui-core": "0.7.2",
"@nodedc/ui-react": "0.7.4",
"cesium": "1.147.0",
"react": "^19.1.0",
"react-dom": "^19.1.0"
@@ -2516,7 +2516,7 @@
},
"packages/ui-core": {
"name": "@nodedc/ui-core",
"version": "0.7.1",
"version": "0.7.2",
"dependencies": {
"@nodedc/tokens": "0.6.0"
}
@@ -2525,17 +2525,17 @@
"name": "@nodedc/ui-dom",
"version": "0.7.0",
"dependencies": {
"@nodedc/ui-core": "0.7.1"
"@nodedc/ui-core": "0.7.2"
}
},
"packages/ui-react": {
"name": "@nodedc/ui-react",
"version": "0.7.3",
"version": "0.7.4",
"dependencies": {
"@dnd-kit/core": "^6.3.1",
"@dnd-kit/sortable": "^10.0.0",
"@dnd-kit/utilities": "^3.2.2",
"@nodedc/ui-core": "0.7.1",
"@nodedc/ui-core": "0.7.2",
"lucide-react": "^0.468.0"
},
"devDependencies": {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@nodedc/ui-core",
"version": "0.7.1",
"version": "0.7.2",
"type": "module",
"files": [
"dist",
+28 -2
View File
@@ -3002,7 +3002,7 @@ textarea.nodedc-field__control {
.nodedc-workspace-window__head:focus-visible {
background: var(--nodedc-focus-surface);
box-shadow: inset 0 0 0 1px rgb(var(--nodedc-accent-rgb) / 0.22);
box-shadow: none;
}
.nodedc-workspace-window[data-maximized="true"] .nodedc-workspace-window__head {
@@ -4637,7 +4637,7 @@ textarea.nodedc-field__control {
.nodedc-editor-dock :is(.nodedc-editor-dock__tool,.nodedc-editor-dock__primary)[data-dock-corners~="bottom-left"] {border-bottom-left-radius:var(--nodedc-radius-panel);}
.nodedc-editor-dock__tool>.nodedc-window__head {flex:none;cursor:grab;touch-action:none;user-select:none;}
.nodedc-editor-dock__tool>.nodedc-window__head:active {cursor:grabbing;}
.nodedc-editor-dock__tool>.nodedc-window__head:focus-visible {outline:2px solid var(--nodedc-text-primary);outline-offset:-3px;}
.nodedc-editor-dock__tool>.nodedc-window__head:focus-visible :is(.nodedc-window__title,.nodedc-window__subtitle,.nodedc-window__actions,.nodedc-window__close,.nodedc-icon-button) {color:inherit;}
.nodedc-editor-dock__body {flex:1;min-height:0;min-width:0;overflow-x:hidden;overflow-y:auto;overscroll-behavior:contain;padding:0 var(--nodedc-space-3) var(--nodedc-space-3);}
.nodedc-editor-dock__tool .nodedc-inspector {width:100%;max-width:none;}
@@ -4858,3 +4858,29 @@ textarea.nodedc-field__control {
.nodedc-range[data-variant="rail"] input[type="range"] { top: 50%; height: max(100%, 24px); transform: translateY(-50%); }
.nodedc-range-rail:has(input:focus-visible) .nodedc-range-rail__value { text-decoration: underline; text-underline-offset: 2px; }
.nodedc-range-rail[data-disabled] { opacity: var(--nodedc-disabled-opacity, 0.5); }
/* Shared move handles: no browser perimeter or pointer-inherited focus flash.
Keyboard navigation retains the canonical focus surface in every window. */
:is(.nodedc-window__head, .nodedc-workspace-window__head)[tabindex] {
outline: 0;
box-shadow: none;
}
:is(.nodedc-window__head, .nodedc-workspace-window__head)[tabindex]:focus-visible {
outline: 0;
box-shadow: none;
background: var(--nodedc-focus-surface);
}
[data-nodedc-edges="flat"] :is(.nodedc-window__head, .nodedc-workspace-window__head)[tabindex]:focus-visible {
background: var(--nodedc-text-primary);
color: var(--nodedc-canvas);
}
:is(.nodedc-window__head, .nodedc-workspace-window__head)[tabindex]:focus-visible :is(.nodedc-window__title, .nodedc-window__subtitle, .nodedc-workspace-window__title, .nodedc-workspace-window__subtitle) {
color: inherit;
}
[data-nodedc-edges] :is(.nodedc-window__head, .nodedc-workspace-window__head)[tabindex][data-pointer-focus="true"],
:is(.nodedc-window__head, .nodedc-workspace-window__head)[tabindex][data-pointer-focus="true"] {
outline: 0;
box-shadow: none;
background: transparent;
color: var(--nodedc-text-primary);
}
+1 -1
View File
@@ -20,6 +20,6 @@
"typecheck": "tsc -p tsconfig.json --noEmit"
},
"dependencies": {
"@nodedc/ui-core": "0.7.1"
"@nodedc/ui-core": "0.7.2"
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@nodedc/ui-react",
"version": "0.7.3",
"version": "0.7.4",
"type": "module",
"files": [
"dist"
@@ -21,7 +21,7 @@
"@dnd-kit/core": "^6.3.1",
"@dnd-kit/sortable": "^10.0.0",
"@dnd-kit/utilities": "^3.2.2",
"@nodedc/ui-core": "0.7.1",
"@nodedc/ui-core": "0.7.2",
"lucide-react": "^0.468.0"
},
"peerDependencies": {
+2 -1
View File
@@ -1,3 +1,4 @@
import {dragHandleFocus} from './dragHandleFocus.js';
import {useEffect,useLayoutEffect,useRef,useState,type KeyboardEvent,type PointerEvent,type ReactNode} from 'react';
import {constrainDockTree,dockIds,dockMinimum,dockRects,dockEditorTool,editorDockTarget,mergeEditorDockRatios,pruneDockTree,resizeDockSplit,type DockMinimum,type DockMove,type DockRect,type DockTree,type EditorDockState} from '@nodedc/ui-core';
import {IconButton} from './Button.js';
@@ -105,7 +106,7 @@ export function EditorDockLayout({value,onChange,primary,primaryId='viewport',pr
return <div key={tool.id} className={cn('nodedc-editor-dock__tool nodedc-glass-material nodedc-ui-root',tool.className)} data-editor-tool={tool.id} data-floating={free||undefined} data-glass-context={free?'scene':undefined} data-dock-corners={free?undefined:editorDockCorners(rect,area)} data-active={order.at(-1)===tool.id||undefined}
role="region" aria-label={tool.label} hidden={!enabled||!tool.open} style={{...rect,zIndex:moving?40:free?10+Math.max(0,order.indexOf(tool.id)):1}}
onPointerDownCapture={()=>activate(tool.id)} onFocusCapture={()=>activate(tool.id)}>
<header className="nodedc-window__head" tabIndex={0} aria-label={`Переместить · ${tool.label}`} aria-roledescription="Перемещаемая панель" onPointerDown={e=>begin(tool.id,e)} onKeyDown={e=>key(tool.id,e)}>
<header {...dragHandleFocus} className="nodedc-window__head" tabIndex={0} aria-label={`Переместить · ${tool.label}`} aria-roledescription="Перемещаемая панель" onPointerDown={e=>begin(tool.id,e)} onKeyDown={e=>key(tool.id,e)}>
<div className="nodedc-window__titles"><h2 className="nodedc-window__title">{tool.title}</h2>{tool.subtitle&&<p className="nodedc-window__subtitle">{tool.subtitle}</p>}</div>
<div className="nodedc-window__actions">{tool.actions}<IconButton label={`Закрыть · ${tool.label}`} onClick={tool.onClose}><Icon name="close"/></IconButton></div>
</header>
+2
View File
@@ -1,3 +1,4 @@
import {dragHandleFocus} from './dragHandleFocus.js';
import {
useCallback,
useEffect,
@@ -262,6 +263,7 @@ export function Window({
{...props}
>
<header
{...dragHandleFocus}
className="nodedc-window__head"
tabIndex={freeGeometry ? 0 : undefined}
aria-label={freeGeometry ? "Перемещение окна: стрелки; изменение размера: Shift и стрелки" : undefined}
@@ -1,3 +1,4 @@
import {dragHandleFocus} from './dragHandleFocus.js';
import {
useEffect,
useId,
@@ -397,6 +398,7 @@ export function WorkspaceWindow({
}}
>
<header
{...dragHandleFocus}
ref={headRef}
className="nodedc-workspace-window__head"
tabIndex={maximized ? -1 : 0}
+15
View File
@@ -0,0 +1,15 @@
import type {FocusEvent, KeyboardEvent, PointerEvent} from 'react';
/** A pointer grab must not inherit the previous input's keyboard focus ring. */
export const dragHandleFocus = {
onPointerDownCapture(event: PointerEvent<HTMLElement>) {
if (event.button !== 0 || (event.target as HTMLElement).closest('button,input,select,textarea,a,[role=slider]')) return;
event.currentTarget.dataset.pointerFocus = 'true';
},
onKeyDownCapture(event: KeyboardEvent<HTMLElement>) {
if (event.target === event.currentTarget) delete event.currentTarget.dataset.pointerFocus;
},
onBlur(event: FocusEvent<HTMLElement>) {
if (event.target === event.currentTarget) delete event.currentTarget.dataset.pointerFocus;
},
};
+6 -3
View File
@@ -465,7 +465,8 @@
"Inspectors inside a Window use its full available content width.",
"End inspectors opt into resizable with an optional initialRect; existing eight edge geometry and keyboard resize are shared with floating windows.",
"Application-owned rect restores modeless window geometry on reopen and external undo/import. onRectCommit reports one completed drag/resize or keyboard step; viewport fitting never overwrites saved geometry.",
"Enforced operational typography: independent md/13px base for UI roots and portals; section/value text md, Description/status/error copy sm/12px, only canonical page/window titles use title/18px. Shared build-time typography contract and catalog example prevent browser-default size regressions."
"Enforced operational typography: independent md/13px base for UI roots and portals; section/value text md, Description/status/error copy sm/12px, only canonical page/window titles use title/18px. Shared build-time typography contract and catalog example prevent browser-default size regressions.",
"Drag headers never draw perimeter outlines or inherit keyboard-focus fill on pointer grab. Keyboard focus remains visible through the canonical surface; arrows, Shift+arrows and docking shortcuts remain available."
]
},
{
@@ -504,7 +505,8 @@
"resizeIndicator=false hides only the corner glyph; pointer hit area, cursor and keyboard resizing remain available.",
"Use WorkspaceWindow for auxiliary views inside a stage; modal workflows and viewport inspectors continue to use Window.",
"Dragging and resizing remain clamped when the workspace changes size, including when it becomes smaller than the requested minimum.",
"Enforced operational typography: independent md/13px base for UI roots and portals; section/value text md, Description/status/error copy sm/12px, only canonical page/window titles use title/18px. Shared build-time typography contract and catalog example prevent browser-default size regressions."
"Enforced operational typography: independent md/13px base for UI roots and portals; section/value text md, Description/status/error copy sm/12px, only canonical page/window titles use title/18px. Shared build-time typography contract and catalog example prevent browser-default size regressions.",
"Drag headers never draw perimeter outlines or inherit keyboard-focus fill on pointer grab. Keyboard focus remains visible through the canonical surface; arrows, Shift+arrows and docking shortcuts remain available."
]
},
{
@@ -1422,7 +1424,8 @@
"The fixed editor header is outside docking bounds. Back, edit completion and close return to the original view.",
"When opened inside Window, the editor suspends that overlay, backdrop and focus trap without unmounting; returning restores the same window.",
"EditorWorkspace purpose=view uses the same mounted host, return/fullscreen behavior and optional fixed headerActions; purpose=edit remains the compatible default.",
"Tool minimumSize applies to floating restore, pointer and keyboard resize as well as docked splits; small screens clamp to available space. Footer remains outside the body scroller."
"Tool minimumSize applies to floating restore, pointer and keyboard resize as well as docked splits; small screens clamp to available space. Footer remains outside the body scroller.",
"Drag headers never draw perimeter outlines or inherit keyboard-focus fill on pointer grab. Keyboard focus remains visible through the canonical surface; arrows, Shift+arrows and docking shortcuts remain available."
]
},
{