-
Notifications
You must be signed in to change notification settings - Fork 672
DataGrid: Fix horizontal touch scrolling on freespace row with rowDragging enabled (T1329643) #34116
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
Open
Alyar666
wants to merge
3
commits into
DevExpress:26_1
Choose a base branch
from
Alyar666:T1329643_26_1
base: 26_1
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+180
−13
Open
DataGrid: Fix horizontal touch scrolling on freespace row with rowDragging enabled (T1329643) #34116
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
133 changes: 133 additions & 0 deletions
133
packages/devextreme/js/__internal/__tests__/draggable.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,133 @@ | ||
| import { | ||
| afterEach, | ||
| beforeEach, | ||
| describe, | ||
| expect, | ||
| it, | ||
| } from '@jest/globals'; | ||
| import eventsEngine from '@js/common/core/events/core/events_engine'; | ||
| import type { dxElementWrapper } from '@js/core/renderer'; | ||
| import $ from '@js/core/renderer'; | ||
| import Draggable from '@js/ui/draggable'; | ||
|
|
||
| const DRAGGABLE_ELEMENT_ID = 'draggable'; | ||
|
|
||
| interface DraggableTest extends Draggable { | ||
| getDragInProgress: () => boolean; | ||
| } | ||
|
|
||
| interface FiredEvent { | ||
| _cancelPreventDefault?: boolean; | ||
| isDefaultPrevented: () => boolean; | ||
| } | ||
|
|
||
| const fire = (element: Element, type: string, x = 0, y = 0): FiredEvent => { | ||
| // @ts-expect-error -- Event is absent from the public eventsEngine type | ||
| const event: FiredEvent = eventsEngine.Event({ | ||
| type, | ||
| pageX: x, | ||
| pageY: y, | ||
| clientX: x, | ||
| clientY: y, | ||
| offset: { x, y }, | ||
| pointerType: 'touch', | ||
| pointers: type === 'dxpointerup' ? [] : [{ pointerId: 1 }], | ||
| pointerId: 1, | ||
| which: 1, | ||
| }); | ||
|
|
||
| // @ts-expect-error -- trigger is absent from the public eventsEngine type | ||
| eventsEngine.trigger(element, event); | ||
|
|
||
| return event; | ||
| }; | ||
|
|
||
| const swipe = (target: Element): void => { | ||
| fire(target, 'dxpointerdown', 0, 0); | ||
| fire(target, 'dxpointermove', 0, 20); | ||
| fire(target, 'dxpointermove', 0, 40); | ||
| fire(target, 'dxpointerup', 0, 40); | ||
| }; | ||
|
|
||
| const appendElement = (): dxElementWrapper => $('<div>') | ||
| .attr('id', DRAGGABLE_ELEMENT_ID) | ||
| .css({ width: '100px', height: '40px' }) | ||
| .appendTo(document.body); | ||
|
|
||
| const createDraggable = (options: Record<string, unknown> = {}): DraggableTest => { | ||
| const $element = appendElement(); | ||
|
|
||
| return new Draggable($element.get(0), { autoScroll: false, ...options }) as DraggableTest; | ||
| }; | ||
|
|
||
| beforeEach(() => { | ||
| document.body.innerHTML = ''; | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| const instance = Draggable.getInstance($(`#${DRAGGABLE_ELEMENT_ID}`).get(0)); | ||
|
|
||
| instance?.dispose(); | ||
| }); | ||
|
|
||
| describe('Draggable dragInProgress reset', () => { | ||
| it('should reset dragInProgress when a drag is completed', () => { | ||
| const draggable = createDraggable(); | ||
|
|
||
| swipe(draggable.$element().get(0)); | ||
|
|
||
| expect(draggable.getDragInProgress()).toBe(false); | ||
| }); | ||
|
|
||
| it('should not set dragInProgress when the drag start is canceled by an invalid handle', () => { | ||
| const draggable = createDraggable({ handle: '.handle' }); | ||
| const $draggableElement = draggable.$element(); | ||
|
|
||
| $('<span>').addClass('handle').appendTo($draggableElement); | ||
|
|
||
| swipe($draggableElement.get(0)); | ||
|
|
||
| expect(draggable.getDragInProgress()).toBe(false); | ||
| }); | ||
|
|
||
| it('should not set dragInProgress when the element is disabled', () => { | ||
| const draggable = createDraggable(); | ||
|
|
||
| draggable.$element().addClass('dx-state-disabled'); | ||
|
|
||
| swipe(draggable.$element().get(0)); | ||
|
|
||
| expect(draggable.getDragInProgress()).toBe(false); | ||
| }); | ||
|
|
||
| it('should not set dragInProgress when onDragStart cancels the drag', () => { | ||
| const draggable = createDraggable({ | ||
| onDragStart: (e) => { e.cancel = true; }, | ||
| }); | ||
|
|
||
| swipe(draggable.$element().get(0)); | ||
|
|
||
| expect(draggable.getDragInProgress()).toBe(false); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Draggable preventDefault on a drag move', () => { | ||
| it('should not prevent default on a drag move when no drag is in progress', () => { | ||
| const draggable = createDraggable(); | ||
| const event = fire(draggable.$element().get(0), 'dxdrag'); | ||
|
|
||
| expect(event._cancelPreventDefault).toBe(true); | ||
| expect(event.isDefaultPrevented()).toBe(false); | ||
| }); | ||
|
|
||
| it('should prevent default on a drag move when a drag is in progress', () => { | ||
| const draggable = createDraggable(); | ||
| const element = draggable.$element().get(0); | ||
|
|
||
| fire(element, 'dxpointerdown', 0, 0); | ||
| const event = fire(element, 'dxpointermove', 0, 20); | ||
|
|
||
| expect(event._cancelPreventDefault).not.toBe(true); | ||
| expect(event.isDefaultPrevented()).toBe(true); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.