mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-22 03:38:11 +08:00
Make Data panel scalars selectable inline, denoise float display, and standardize breadcrumb string truncation (#4470)
* Make Data panel scalars selectable inline, denoise float display, and move breadcrumb truncation to Rust * Code review fixes * Remove denoising from f32
This commit is contained in:
@@ -128,6 +128,7 @@ export function onPointerMove(e: PointerEvent, editor: EditorWrapper, documentSt
|
||||
|
||||
export function onPointerDown(e: PointerEvent, editor: EditorWrapper, dialogStore: DialogStore) {
|
||||
potentiallyRestoreCanvasFocus(e);
|
||||
potentiallyClearTextSelection(e);
|
||||
|
||||
const inFloatingMenu = e.target instanceof Element && e.target.closest("[data-floating-menu-content]");
|
||||
const isTargetingCanvas = !inFloatingMenu && e.target instanceof Element && e.target.closest("[data-viewport], [data-viewport-container], [data-node-graph]");
|
||||
@@ -351,6 +352,20 @@ function targetIsTextField(target: EventTarget | HTMLElement | undefined): boole
|
||||
);
|
||||
}
|
||||
|
||||
function potentiallyClearTextSelection(e: PointerEvent) {
|
||||
const target = e.target instanceof Element ? e.target : undefined;
|
||||
if (target && (targetIsTextField(target) || window.getComputedStyle(target).userSelect !== "none")) return;
|
||||
|
||||
// A text control's selection lives in its shadow tree, which the document's `Selection` reports as collapsed and cannot clear, so each control holding one is collapsed through its own API
|
||||
const controls = window.document.querySelectorAll<HTMLInputElement | HTMLTextAreaElement>("textarea, input[type='text']");
|
||||
controls.forEach((control) => {
|
||||
const caret = control.selectionStart;
|
||||
if (typeof caret === "number" && caret !== control.selectionEnd) control.setSelectionRange(caret, caret);
|
||||
});
|
||||
|
||||
window.getSelection()?.removeAllRanges();
|
||||
}
|
||||
|
||||
function potentiallyRestoreCanvasFocus(e: Event) {
|
||||
const appElement = window.document.querySelector("[data-app-container]");
|
||||
const app = appElement instanceof HTMLElement ? appElement : undefined;
|
||||
|
||||
Reference in New Issue
Block a user