@vaadin/vaadin-grid 5.9.5 → 5.9.6

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
@@ -15,7 +15,7 @@
15
15
  "repository": "vaadin/vaadin-grid",
16
16
  "homepage": "https://vaadin.com/components",
17
17
  "name": "@vaadin/vaadin-grid",
18
- "version": "5.9.5",
18
+ "version": "5.9.6",
19
19
  "main": "vaadin-grid.js",
20
20
  "author": "Vaadin Ltd",
21
21
  "license": "Apache-2.0",
@@ -82,11 +82,8 @@ class GridColumnGroupElement extends ColumnBaseMixin(PolymerElement) {
82
82
 
83
83
  static get observers() {
84
84
  return [
85
- '_updateVisibleChildColumns(_childColumns)',
86
- '_childColumnsChanged(_childColumns)',
87
85
  '_groupFrozenChanged(frozen, _rootColumns)',
88
- '_groupHiddenChanged(hidden, _rootColumns)',
89
- '_visibleChildColumnsChanged(_visibleChildColumns)',
86
+ '_groupHiddenChanged(hidden)',
90
87
  '_colSpanChanged(_colSpan, _headerCell, _footerCell)',
91
88
  '_groupOrderChanged(_order, _rootColumns)',
92
89
  '_groupReorderStatusChanged(_reorderStatus, _rootColumns)',
@@ -114,9 +111,12 @@ class GridColumnGroupElement extends ColumnBaseMixin(PolymerElement) {
114
111
  */
115
112
  _columnPropChanged(path, value) {
116
113
  if (path === 'hidden') {
117
- this._preventHiddenCascade = true;
114
+ // Prevent synchronization of the hidden state to child columns.
115
+ // If the group is currently auto-hidden, and one column is made visible,
116
+ // we don't want the other columns to become visible as well.
117
+ this._preventHiddenSynchronization = true;
118
118
  this._updateVisibleChildColumns(this._childColumns);
119
- this._preventHiddenCascade = false;
119
+ this._preventHiddenSynchronization = false;
120
120
  }
121
121
 
122
122
  if (/flexGrow|width|hidden|_childColumns/.test(path)) {
@@ -188,15 +188,9 @@ class GridColumnGroupElement extends ColumnBaseMixin(PolymerElement) {
188
188
 
189
189
  /** @private */
190
190
  _updateVisibleChildColumns(childColumns) {
191
- this._visibleChildColumns = Array.prototype.filter.call(childColumns, col => !col.hidden);
192
- }
193
-
194
- /** @private */
195
- _childColumnsChanged(childColumns) {
196
- if (!this._autoHidden && this.hidden) {
197
- Array.prototype.forEach.call(childColumns, column => column.hidden = true);
198
- this._updateVisibleChildColumns(childColumns);
199
- }
191
+ this._visibleChildColumns = Array.prototype.filter.call(childColumns, (col) => !col.hidden);
192
+ this._colSpan = this._visibleChildColumns.length;
193
+ this._updateAutoHidden();
200
194
  }
201
195
 
202
196
  /** @protected */
@@ -230,26 +224,31 @@ class GridColumnGroupElement extends ColumnBaseMixin(PolymerElement) {
230
224
  }
231
225
 
232
226
  /** @private */
233
- _groupHiddenChanged(hidden, rootColumns) {
234
- if (rootColumns && !this._preventHiddenCascade) {
235
- this._ignoreVisibleChildColumns = true;
236
- rootColumns.forEach(column => column.hidden = hidden);
237
- this._ignoreVisibleChildColumns = false;
227
+ _groupHiddenChanged(hidden) {
228
+ // When initializing the hidden property, only sync hidden state to columns
229
+ // if group is actually hidden. Otherwise, we could override a hidden column
230
+ // to be visible.
231
+ // We always want to run this though if the property is actually changed.
232
+ if (hidden || this.__groupHiddenInitialized) {
233
+ this._synchronizeHidden();
238
234
  }
235
+ this.__groupHiddenInitialized = true;
236
+ }
239
237
 
240
- this._columnPropChanged('hidden');
238
+ /** @private */
239
+ _updateAutoHidden() {
240
+ const wasAutoHidden = this._autoHidden;
241
+ this._autoHidden = (this._visibleChildColumns || []).length === 0;
242
+ // Only modify hidden state if group was auto-hidden, or becomes auto-hidden
243
+ if (wasAutoHidden || this._autoHidden) {
244
+ this.hidden = this._autoHidden;
245
+ }
241
246
  }
242
247
 
243
248
  /** @private */
244
- _visibleChildColumnsChanged(visibleChildColumns) {
245
- this._colSpan = visibleChildColumns.length;
246
-
247
- if (!this._ignoreVisibleChildColumns) {
248
- if (visibleChildColumns.length === 0) {
249
- this._autoHidden = this.hidden = true;
250
- } else if (this.hidden && this._autoHidden) {
251
- this._autoHidden = this.hidden = false;
252
- }
249
+ _synchronizeHidden() {
250
+ if (this._childColumns && !this._preventHiddenSynchronization) {
251
+ this._childColumns.forEach((column) => (column.hidden = this.hidden));
253
252
  }
254
253
  }
255
254
 
@@ -280,10 +279,14 @@ class GridColumnGroupElement extends ColumnBaseMixin(PolymerElement) {
280
279
  if (info.addedNodes.filter(this._isColumnElement).length > 0 ||
281
280
  info.removedNodes.filter(this._isColumnElement).length > 0) {
282
281
 
283
- this._preventHiddenCascade = true;
282
+ // Prevent synchronization of the hidden state to child columns.
283
+ // If the group is currently auto-hidden, and a visible column is added,
284
+ // we don't want the other columns to become visible as well.
285
+ this._preventHiddenSynchronization = true;
284
286
  this._rootColumns = this._getChildColumns(this);
285
287
  this._childColumns = this._rootColumns;
286
- this._preventHiddenCascade = false;
288
+ this._updateVisibleChildColumns(this._childColumns);
289
+ this._preventHiddenSynchronization = false;
287
290
 
288
291
  // Update the column tree with microtask timing to avoid shady style scope issues
289
292
  microTask.run(() => {
@@ -310,10 +310,6 @@ export const ColumnBaseMixin = superClass => class ColumnBaseMixin extends super
310
310
 
311
311
  /** @private */
312
312
  __setColumnTemplateOrRenderer(template, renderer, cells) {
313
- // no renderer or template needed in a hidden column
314
- if (this.hidden) {
315
- return;
316
- }
317
313
  if (template && renderer) {
318
314
  throw new Error('You should only use either a renderer or a template');
319
315
  }
@@ -325,7 +325,7 @@ class GridElement extends
325
325
  }
326
326
 
327
327
  static get version() {
328
- return '5.9.5';
328
+ return '5.9.6';
329
329
  }
330
330
 
331
331
  static get observers() {