fix(ui): keep drag handles free of pointer focus outlines
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nodedc/ui-core",
|
||||
"version": "0.7.1",
|
||||
"version": "0.7.2",
|
||||
"type": "module",
|
||||
"files": [
|
||||
"dist",
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,6 @@
|
||||
"typecheck": "tsc -p tsconfig.json --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nodedc/ui-core": "0.7.1"
|
||||
"@nodedc/ui-core": "0.7.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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;
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user