Skip to content
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

refactor: use the shared _getGridEventLocation method #7452

Merged
merged 2 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions packages/grid-pro/src/vaadin-grid-pro-inline-editing-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,7 @@ export const InlineEditingMixin = (superClass) =>
const edited = this.__edited;

if (context.item && this._isEditColumn(column)) {
const path = e.composedPath();
const cell = path[path.indexOf(this.$.table) - 3];
const { cell } = this._getGridEventLocation(e);

if (!cell || cell.getAttribute('part').indexOf('details-cell') > -1) {
return;
Expand Down Expand Up @@ -278,8 +277,7 @@ export const InlineEditingMixin = (superClass) =>
const edited = this.__edited;

if (context.item && this._isEditColumn(column)) {
const path = e.composedPath();
const cell = path[path.indexOf(this.$.table) - 3];
const { cell } = this._getGridEventLocation(e);

if (!cell || cell.getAttribute('part').indexOf('details-cell') > -1) {
return;
Expand Down
3 changes: 1 addition & 2 deletions packages/grid/src/vaadin-grid-active-item-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ export const ActiveItemMixin = (superClass) =>
return;
}

const path = e.composedPath();
const cell = path[path.indexOf(this.$.table) - 3];
const { cell } = this._getGridEventLocation(e);
if (!cell || cell.getAttribute('part').indexOf('details-cell') > -1 || cell === this.$.emptystatecell) {
return;
}
Expand Down
5 changes: 1 addition & 4 deletions packages/grid/src/vaadin-grid-event-context-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ export const EventContextMixin = (superClass) =>
getEventContext(event) {
const context = {};

// Use `composedPath()` stored by vaadin-context-menu gesture
// to avoid problem when accessing it after a timeout on iOS
const path = event.__composedPath || event.composedPath();
const cell = path[path.indexOf(this.$.table) - 3];
const { cell } = this._getGridEventLocation(event);

if (!cell) {
return context;
Expand Down
6 changes: 4 additions & 2 deletions packages/grid/src/vaadin-grid-keyboard-navigation-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -1069,10 +1069,12 @@ export const KeyboardNavigationMixin = (superClass) =>
* The event may either target table section, a row, a cell or contents of a cell.
* @param {Event} e
* @returns {GridEventLocation}
* @private
* @protected
*/
_getGridEventLocation(e) {
const path = e.composedPath();
// Use `composedPath()` stored by vaadin-context-menu gesture
// to avoid problem when accessing it after a timeout on iOS
const path = e.__composedPath || e.composedPath();
const tableIndex = path.indexOf(this.$.table);
// Assuming ascending path to table is: [...,] th|td, tr, thead|tbody, table [,...]
const section = tableIndex >= 1 ? path[tableIndex - 1] : null;
Expand Down
Loading