@vaadin/grid 22.0.11 → 22.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/grid",
3
- "version": "22.0.11",
3
+ "version": "22.0.14",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -40,19 +40,19 @@
40
40
  "dependencies": {
41
41
  "@open-wc/dedupe-mixin": "^1.3.0",
42
42
  "@polymer/polymer": "^3.0.0",
43
- "@vaadin/checkbox": "^22.0.11",
44
- "@vaadin/component-base": "^22.0.11",
45
- "@vaadin/text-field": "^22.0.11",
46
- "@vaadin/vaadin-lumo-styles": "^22.0.11",
47
- "@vaadin/vaadin-material-styles": "^22.0.11",
48
- "@vaadin/vaadin-themable-mixin": "^22.0.11"
43
+ "@vaadin/checkbox": "^22.0.14",
44
+ "@vaadin/component-base": "^22.0.14",
45
+ "@vaadin/text-field": "^22.0.14",
46
+ "@vaadin/vaadin-lumo-styles": "^22.0.14",
47
+ "@vaadin/vaadin-material-styles": "^22.0.14",
48
+ "@vaadin/vaadin-themable-mixin": "^22.0.14"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@esm-bundle/chai": "^4.3.4",
52
- "@vaadin/polymer-legacy-adapter": "^22.0.11",
52
+ "@vaadin/polymer-legacy-adapter": "^22.0.14",
53
53
  "@vaadin/testing-helpers": "^0.3.2",
54
54
  "lit": "^2.0.0",
55
55
  "sinon": "^9.2.0"
56
56
  },
57
- "gitHead": "a905b1ef7af885ce5536646e818fe76574407237"
57
+ "gitHead": "62419e3f8f41fe9dc4f0bce5e1717b16828459b6"
58
58
  }
@@ -85,11 +85,8 @@ class GridColumnGroup extends ColumnBaseMixin(PolymerElement) {
85
85
 
86
86
  static get observers() {
87
87
  return [
88
- '_updateVisibleChildColumns(_childColumns)',
89
- '_childColumnsChanged(_childColumns)',
90
88
  '_groupFrozenChanged(frozen, _rootColumns)',
91
- '_groupHiddenChanged(hidden, _rootColumns)',
92
- '_visibleChildColumnsChanged(_visibleChildColumns)',
89
+ '_groupHiddenChanged(hidden)',
93
90
  '_colSpanChanged(_colSpan, _headerCell, _footerCell)',
94
91
  '_groupOrderChanged(_order, _rootColumns)',
95
92
  '_groupReorderStatusChanged(_reorderStatus, _rootColumns)',
@@ -117,9 +114,12 @@ class GridColumnGroup extends ColumnBaseMixin(PolymerElement) {
117
114
  */
118
115
  _columnPropChanged(path, value) {
119
116
  if (path === 'hidden') {
120
- this._preventHiddenCascade = true;
117
+ // Prevent synchronization of the hidden state to child columns.
118
+ // If the group is currently auto-hidden, and one column is made visible,
119
+ // we don't want the other columns to become visible as well.
120
+ this._preventHiddenSynchronization = true;
121
121
  this._updateVisibleChildColumns(this._childColumns);
122
- this._preventHiddenCascade = false;
122
+ this._preventHiddenSynchronization = false;
123
123
  }
124
124
 
125
125
  if (/flexGrow|width|hidden|_childColumns/.test(path)) {
@@ -192,14 +192,8 @@ class GridColumnGroup extends ColumnBaseMixin(PolymerElement) {
192
192
  /** @private */
193
193
  _updateVisibleChildColumns(childColumns) {
194
194
  this._visibleChildColumns = Array.prototype.filter.call(childColumns, (col) => !col.hidden);
195
- }
196
-
197
- /** @private */
198
- _childColumnsChanged(childColumns) {
199
- if (!this._autoHidden && this.hidden) {
200
- Array.prototype.forEach.call(childColumns, (column) => (column.hidden = true));
201
- this._updateVisibleChildColumns(childColumns);
202
- }
195
+ this._colSpan = this._visibleChildColumns.length;
196
+ this._updateAutoHidden();
203
197
  }
204
198
 
205
199
  /** @protected */
@@ -240,26 +234,31 @@ class GridColumnGroup extends ColumnBaseMixin(PolymerElement) {
240
234
  }
241
235
 
242
236
  /** @private */
243
- _groupHiddenChanged(hidden, rootColumns) {
244
- if (rootColumns && !this._preventHiddenCascade) {
245
- this._ignoreVisibleChildColumns = true;
246
- rootColumns.forEach((column) => (column.hidden = hidden));
247
- this._ignoreVisibleChildColumns = false;
237
+ _groupHiddenChanged(hidden) {
238
+ // When initializing the hidden property, only sync hidden state to columns
239
+ // if group is actually hidden. Otherwise, we could override a hidden column
240
+ // to be visible.
241
+ // We always want to run this though if the property is actually changed.
242
+ if (hidden || this.__groupHiddenInitialized) {
243
+ this._synchronizeHidden();
248
244
  }
245
+ this.__groupHiddenInitialized = true;
246
+ }
249
247
 
250
- this._columnPropChanged('hidden');
248
+ /** @private */
249
+ _updateAutoHidden() {
250
+ const wasAutoHidden = this._autoHidden;
251
+ this._autoHidden = (this._visibleChildColumns || []).length === 0;
252
+ // Only modify hidden state if group was auto-hidden, or becomes auto-hidden
253
+ if (wasAutoHidden || this._autoHidden) {
254
+ this.hidden = this._autoHidden;
255
+ }
251
256
  }
252
257
 
253
258
  /** @private */
254
- _visibleChildColumnsChanged(visibleChildColumns) {
255
- this._colSpan = visibleChildColumns.length;
256
-
257
- if (!this._ignoreVisibleChildColumns) {
258
- if (visibleChildColumns.length === 0) {
259
- this._autoHidden = this.hidden = true;
260
- } else if (this.hidden && this._autoHidden) {
261
- this._autoHidden = this.hidden = false;
262
- }
259
+ _synchronizeHidden() {
260
+ if (this._childColumns && !this._preventHiddenSynchronization) {
261
+ this._childColumns.forEach((column) => (column.hidden = this.hidden));
263
262
  }
264
263
  }
265
264
 
@@ -291,10 +290,14 @@ class GridColumnGroup extends ColumnBaseMixin(PolymerElement) {
291
290
  info.addedNodes.filter(this._isColumnElement).length > 0 ||
292
291
  info.removedNodes.filter(this._isColumnElement).length > 0
293
292
  ) {
294
- this._preventHiddenCascade = true;
293
+ // Prevent synchronization of the hidden state to child columns.
294
+ // If the group is currently auto-hidden, and a visible column is added,
295
+ // we don't want the other columns to become visible as well.
296
+ this._preventHiddenSynchronization = true;
295
297
  this._rootColumns = this._getChildColumns(this);
296
298
  this._childColumns = this._rootColumns;
297
- this._preventHiddenCascade = false;
299
+ this._updateVisibleChildColumns(this._childColumns);
300
+ this._preventHiddenSynchronization = false;
298
301
 
299
302
  // Update the column tree with microtask timing to avoid shady style scope issues
300
303
  microTask.run(() => {
@@ -620,6 +620,11 @@ export const KeyboardNavigationMixin = (superClass) =>
620
620
  _onTabKeyDown(e) {
621
621
  const focusTarget = this._predictFocusStepTarget(e.composedPath()[0], e.shiftKey ? -1 : 1);
622
622
 
623
+ // Can be undefined if grid has tabindex
624
+ if (!focusTarget) {
625
+ return;
626
+ }
627
+
623
628
  // Prevent focus-trap logic from intercepting the event.
624
629
  e.stopPropagation();
625
630
 
@@ -664,7 +664,7 @@ class Grid extends ElementMixin(
664
664
  // If focus is on element within the cell content — respect it, do not change
665
665
  const contentContainsFocusedElement = cellContent.contains(this.getRootNode().activeElement);
666
666
  // Only focus if mouse is released on cell content itself
667
- const mouseUpWithinCell = cellContent.contains(event.target);
667
+ const mouseUpWithinCell = event.composedPath().includes(cellContent);
668
668
  if (!contentContainsFocusedElement && mouseUpWithinCell) {
669
669
  cell.focus();
670
670
  }
@@ -888,7 +888,8 @@ class Grid extends ElementMixin(
888
888
  }
889
889
 
890
890
  __updateFooterPositioning() {
891
- if (this._firefox) {
891
+ // TODO: fixed in Firefox 99, remove when we can drop Firefox ESR 91 support
892
+ if (this._firefox && parseFloat(navigator.userAgent.match(/Firefox\/(\d{2,3}.\d)/)[1]) < 99) {
892
893
  // Sticky (or translated) footer in a flexbox host doesn't get included in
893
894
  // the scroll height calculation on FF. This is a workaround for the issue.
894
895
  this.$.items.style.paddingBottom = 0;