-
Notifications
You must be signed in to change notification settings - Fork 656
DataGrid: fix interaction blocking while hovering over the grid header and dragging (T1291988) #31489
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
Merged
Merged
DataGrid: fix interaction blocking while hovering over the grid header and dragging (T1291988) #31489
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f491e40
DataGrid: fix interaction blocking while hovering over header if ther…
dmirgaev d71f149
DataGrid: fix interaction blocking while dragging a column if there a…
dmirgaev 375204e
DataGrid: fix interaction blocking while dragging a column (T1291988)
dmirgaev f34a7bd
fix(DataGrid): improve types description
dmirgaev d4831ea
fix(DataGrid): move draggingPanelBoundingRects to _dragOptions property
dmirgaev 6599c7f
fix(DataGrid): fix jsdoc
dmirgaev cfb456c
fix(DataGrid): fix QUnit tests
dmirgaev e5bbbeb
test(DataGrid): add unit tests for utils
dmirgaev ffe2b7f
test(DataGrid): add integration tests
dmirgaev c31cb81
fix(DataGrid): simplify the "_ pointCreated" method
dmirgaev 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
There are no files selected for viewing
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
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
183 changes: 183 additions & 0 deletions
183
...s/grid_core/columns_resizing_reordering/m_columns_resizing_reordering.integration.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,183 @@ | ||
| import { | ||
| afterEach, beforeEach, describe, expect, it, jest, | ||
| } from '@jest/globals'; | ||
| import { | ||
| end as dragEventEnd, | ||
| move as dragEventMove, | ||
| start as dragEventStart, | ||
| } from '@js/common/core/events/drag'; | ||
| import type { dxElementWrapper } from '@js/core/renderer'; | ||
| import $ from '@js/core/renderer'; | ||
| import type { Properties as DataGridProperties } from '@js/ui/data_grid'; | ||
| import DataGrid from '@js/ui/data_grid'; | ||
| import errors from '@js/ui/widget/ui.errors'; | ||
| import { DataGridModel } from '@ts/grids/data_grid/__tests__/__mock__/model/data_grid'; | ||
|
|
||
| const SELECTORS = { | ||
| gridContainer: '#gridContainer', | ||
| }; | ||
|
|
||
| const GRID_CONTAINER_ID = 'gridContainer'; | ||
|
|
||
| const createDataGrid = async ( | ||
| options: DataGridProperties = {}, | ||
| ): Promise<{ | ||
| $container: dxElementWrapper; | ||
| component: DataGridModel; | ||
| instance: DataGrid; | ||
| }> => new Promise((resolve) => { | ||
| const $container = $('<div>') | ||
| .attr('id', GRID_CONTAINER_ID) | ||
| .appendTo(document.body); | ||
|
|
||
| const instance = new DataGrid($container.get(0) as HTMLDivElement, options); | ||
| const component = new DataGridModel($container.get(0) as HTMLElement); | ||
|
|
||
| jest.runAllTimers(); | ||
|
|
||
| resolve({ | ||
| $container, | ||
| component, | ||
| instance, | ||
| }); | ||
| }); | ||
|
|
||
| const beforeTest = (): void => { | ||
| jest.useFakeTimers(); | ||
| jest.spyOn(errors, 'log').mockImplementation(jest.fn()); | ||
| }; | ||
|
|
||
| const afterTest = (): void => { | ||
| const $container = $(SELECTORS.gridContainer); | ||
| const dataGrid = ($container as any).dxDataGrid('instance') as DataGrid; | ||
|
|
||
| dataGrid.dispose(); | ||
| $container.remove(); | ||
| jest.clearAllMocks(); | ||
| jest.useRealTimers(); | ||
| }; | ||
|
|
||
| describe('Performance optimization', () => { | ||
| beforeEach(beforeTest); | ||
| afterEach(afterTest); | ||
|
|
||
| const createGridWith200Columns = async (): Promise<{ | ||
| $container: dxElementWrapper; | ||
| component: DataGridModel; | ||
| instance: DataGrid; | ||
| }> => { | ||
| const columns = [ | ||
| { | ||
| dataField: 'id', caption: 'ID', width: '100px', fixed: true, | ||
| }, | ||
| { | ||
| caption: 'Name', | ||
| columns: [ | ||
| { dataField: 'name.first', caption: 'First name', width: '150px' }, | ||
| { dataField: 'name.last', caption: 'Last name', width: '150px' }, | ||
| ], | ||
| }, | ||
| ...Array.from({ length: 198 }, (_, index) => ({ | ||
| dataField: `values.${index}`, | ||
| caption: `Value ${index + 1}`, | ||
| width: '100px', | ||
| })), | ||
| ]; | ||
|
|
||
| const dataSource = [ | ||
| { | ||
| id: 1, | ||
| name: { first: 'John', last: 'Doe' }, | ||
| values: Array.from({ length: 198 }, (_, index) => index + 1), | ||
| }, | ||
| ]; | ||
|
|
||
| return createDataGrid({ | ||
| dataSource, | ||
| columns, | ||
| width: '100%', | ||
| showBorders: true, | ||
| showColumnLines: true, | ||
| allowColumnResizing: true, | ||
| allowColumnReordering: true, | ||
| }); | ||
| }; | ||
|
|
||
| describe('ColumnsResizerViewController', () => { | ||
| it('should call "_pointCreated" 202 times when generating points by columns (1 fixed + 1 group + 2 group children + 198 regular)', async () => { | ||
| const { instance } = await createGridWith200Columns(); | ||
| const columnsResizerController = (instance as any).getController('columnsResizer'); | ||
|
|
||
| const pointCreatedSpy = jest.spyOn(columnsResizerController, '_pointCreated'); | ||
|
|
||
| columnsResizerController.pointsByColumns(); | ||
|
|
||
| expect(pointCreatedSpy).toHaveBeenCalledTimes(202); | ||
| }); | ||
|
|
||
| it('should call "getColumnElements" as many times as there are head rows', async () => { | ||
| const { instance } = await createGridWith200Columns(); | ||
| const columnsResizerController = (instance as any).getController('columnsResizer'); | ||
| const columnHeadersView = (instance as any).getView('columnHeadersView'); | ||
|
|
||
| const columnHeadersViewSpy = jest.spyOn(columnHeadersView, 'getColumnElements'); | ||
|
|
||
| columnsResizerController.pointsByColumns(); | ||
|
|
||
| expect(columnHeadersViewSpy).toHaveBeenCalledTimes(2); | ||
| }); | ||
| }); | ||
|
|
||
| describe('DraggingHeaderViewController', () => { | ||
| const getDragEvent = ( | ||
| eventName: string, | ||
| headerOffset: { left: number; top: number }, | ||
| dragOffset: { left: number; top: number }, | ||
| ) => { | ||
| const dragEndEvent = document.createEvent('CustomEvent') as any; | ||
|
|
||
| dragEndEvent.initCustomEvent(eventName, true, true); | ||
| dragEndEvent.pageX = headerOffset.left + dragOffset.left; | ||
| dragEndEvent.pageY = headerOffset.top + dragOffset.top; | ||
| dragEndEvent.pointerType = 'mouse'; | ||
|
|
||
| return dragEndEvent; | ||
| }; | ||
|
|
||
| it('should call "getBoundingRect" once for each dragging panel view', async () => { | ||
| const { instance } = await createGridWith200Columns(); | ||
| const columnHeadersView = (instance as any).getView('columnHeadersView'); | ||
| const columnChooserView = (instance as any).getView('columnChooserView'); | ||
| const headerPanelView = (instance as any).getView('headerPanel'); | ||
|
|
||
| const getBoundingViewMocks = [ | ||
| jest.spyOn(columnHeadersView, 'getBoundingRect'), | ||
| jest.spyOn(columnChooserView, 'getBoundingRect'), | ||
| jest.spyOn(headerPanelView, 'getBoundingRect'), | ||
| ]; | ||
|
|
||
| const $headerCell = $(columnHeadersView.element()).find('.dx-header-row td').eq(5); | ||
| const headerOffset = $headerCell.offset(); | ||
|
|
||
| if (!headerOffset) { | ||
| throw new Error('Header cell not found'); | ||
| } | ||
|
|
||
| const dragStartOffset = { left: 10, top: 10 }; | ||
| const dragStartEvent = getDragEvent(dragEventStart, headerOffset, dragStartOffset); | ||
| $headerCell.get(0)?.dispatchEvent(dragStartEvent); | ||
|
|
||
| const dragMoveOffset = { left: 500, top: 10 }; | ||
| const dragMoveEvent = getDragEvent(dragEventMove, headerOffset, dragMoveOffset); | ||
| $headerCell.get(0)?.dispatchEvent(dragMoveEvent); | ||
|
|
||
| const dragEndOffset = { left: 500, top: 10 }; | ||
| const dragEndEvent = getDragEvent(dragEventEnd, headerOffset, dragEndOffset); | ||
| $headerCell.get(0)?.dispatchEvent(dragEndEvent); | ||
|
|
||
| getBoundingViewMocks.forEach((getBoundingViewMock) => { | ||
| expect(getBoundingViewMock).toHaveBeenCalledTimes(1); | ||
| }); | ||
| }); | ||
| }); | ||
| }); |
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.
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.