-
Notifications
You must be signed in to change notification settings - Fork 491
fix: dragging (e.g., when selecting text) in Markdown note causes node to drag #8413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -206,6 +206,60 @@ describe('WidgetMarkdown Dual Mode Display', () => { | |
| expect(clickSpy).not.toHaveBeenCalled() | ||
| expect(keydownSpy).not.toHaveBeenCalled() | ||
| }) | ||
|
|
||
| describe('Pointer Event Propagation', () => { | ||
| it('stops pointerdown propagation to prevent node drag during text selection', async () => { | ||
| const widget = createMockWidget('# Test') | ||
| const wrapper = mountComponent(widget, '# Test') | ||
|
|
||
| await clickToEdit(wrapper) | ||
|
|
||
| const textarea = wrapper.find('textarea') | ||
| expect(textarea.exists()).toBe(true) | ||
|
|
||
| const parentPointerdownHandler = vi.fn() | ||
| const wrapperEl = wrapper.element as HTMLElement | ||
| wrapperEl.addEventListener('pointerdown', parentPointerdownHandler) | ||
|
|
||
| await textarea.trigger('pointerdown') | ||
|
|
||
| expect(parentPointerdownHandler).not.toHaveBeenCalled() | ||
| }) | ||
|
|
||
| it('stops pointermove propagation during text selection', async () => { | ||
| const widget = createMockWidget('# Test') | ||
| const wrapper = mountComponent(widget, '# Test') | ||
|
|
||
| await clickToEdit(wrapper) | ||
|
|
||
| const textarea = wrapper.find('textarea') | ||
|
|
||
| const parentPointermoveHandler = vi.fn() | ||
| const wrapperEl = wrapper.element as HTMLElement | ||
| wrapperEl.addEventListener('pointermove', parentPointermoveHandler) | ||
|
|
||
| await textarea.trigger('pointermove') | ||
|
|
||
| expect(parentPointermoveHandler).not.toHaveBeenCalled() | ||
| }) | ||
|
|
||
| it('stops pointerup propagation after text selection', async () => { | ||
| const widget = createMockWidget('# Test') | ||
| const wrapper = mountComponent(widget, '# Test') | ||
|
|
||
| await clickToEdit(wrapper) | ||
|
|
||
| const textarea = wrapper.find('textarea') | ||
|
|
||
| const parentPointerupHandler = vi.fn() | ||
| const wrapperEl = wrapper.element as HTMLElement | ||
| wrapperEl.addEventListener('pointerup', parentPointerupHandler) | ||
|
|
||
| await textarea.trigger('pointerup') | ||
|
|
||
| expect(parentPointerupHandler).not.toHaveBeenCalled() | ||
|
Comment on lines
+211
to
+260
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure pointer-propagation tests actually enter edit mode (dblclick). Consider switching the helper to trigger Suggested update (outside this hunk)const clickToEdit = async (wrapper: ReturnType<typeof mount>) => {
const container = wrapper.find('.widget-markdown')
- await container.trigger('click')
+ await container.trigger('dblclick')
await nextTick()
return container
}🤖 Prompt for AI Agents |
||
| }) | ||
| }) | ||
| }) | ||
|
|
||
| describe('Value Updates', () => { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,9 @@ | |
| } | ||
| }" | ||
| data-capture-wheel="true" | ||
| @pointerdown.capture.stop | ||
| @pointermove.capture.stop | ||
| @pointerup.capture.stop | ||
| @click.stop | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we're stopping pointerdown, do we also need to stop click?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the purposes of extensions / API consistency? |
||
| @keydown.stop | ||
| /> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I'd always rather an instanceof gate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Valid