Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

fix(webv2): stop a curve handle drag turning into a text drag

joshistoastcf22d4b68abe
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/AdjustmentsPopover.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/AdjustmentsPopover.browser.test.tsx
index 10ef172109..f0f7699001 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/AdjustmentsPopover.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/AdjustmentsPopover.browser.test.tsx
@@ -141,6 +141,18 @@ describe('curves editor', () => {
expect(getComputedStyle(svg).backgroundColor).not.toBe('rgba(0, 0, 0, 0)');
});
+ it('makes nothing in the editor selectable, so a drag cannot become a text drag', async () => {
+ // Double-clicking to add a point is a word-select gesture; without this it
+ // latched onto the channel select's label and the next handle press dragged
+ // that selection instead, trailing a floating "Red" across the screen.
+ const svg = await render();
+ const editor = svg.parentElement!;
+
+ expect(getComputedStyle(editor).userSelect).toBe('none');
+ expect(getComputedStyle(svg).userSelect).toBe('none');
+ expect(getComputedStyle(editor.querySelector('button')!).userSelect).toBe('none');
+ });
+
it('keeps the drawing square so pointer coordinates map onto the viewBox', async () => {
const svg = await render();
const rect = svg.getBoundingClientRect();
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/AdjustmentsPopover.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/AdjustmentsPopover.tsx
index 4bcb9a08a1..3f07642677 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/AdjustmentsPopover.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/AdjustmentsPopover.tsx
@@ -54,8 +54,19 @@ const CURVE_SVG_CSS = {
borderRadius: 'l2',
maxWidth: `${CURVE_SIZE}px`,
touchAction: 'none',
+ userSelect: 'none',
width: 'full',
};
+
+/**
+ * Nothing in the editor is selectable text.
+ *
+ * Double-clicking to add a point is a word-select gesture as far as the browser
+ * is concerned, so it would latch onto the nearest text — the channel select's
+ * label. The next press on a handle then dragged *that* selection instead,
+ * trailing a floating "Red" across the screen and abandoning the point drag.
+ */
+const CURVE_EDITOR_CSS = { userSelect: 'none' };
const CURVE_HANDLE_CSS = { cursor: 'grab', _active: { cursor: 'grabbing' } };
const preventDefault = (event: { preventDefault: () => void }): void => event.preventDefault();
@@ -350,6 +361,9 @@ const CurvesEditor = ({ adjustments, onCancel, onCommit, onLive }: CurvesEditorP
const handlePointDown = useCallback(
(event: ReactPointerEvent<SVGCircleElement>) => {
event.stopPropagation();
+ // Keeps the press from also starting a native selection/text drag, which
+ // would hijack the gesture a few pixels in.
+ event.preventDefault();
event.currentTarget.setPointerCapture(event.pointerId);
dragIndexRef.current = Number(event.currentTarget.dataset.index);
dragTargetRef.current = event.currentTarget;
@@ -457,7 +471,7 @@ const CurvesEditor = ({ adjustments, onCancel, onCommit, onLive }: CurvesEditorP
const channelValue = useMemo(() => [channel], [channel]);
return (
- <Stack gap="2">
+ <Stack css={CURVE_EDITOR_CSS} gap="2">
<HStack justify="space-between">
<Text fontSize="xs" fontWeight="medium">
{t('widgets.layers.adjustments.curves')}