@vaadin/grid 23.0.0-alpha5 → 23.0.0-beta1

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": "23.0.0-alpha5",
3
+ "version": "23.0.0-beta1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -41,19 +41,19 @@
41
41
  "dependencies": {
42
42
  "@open-wc/dedupe-mixin": "^1.3.0",
43
43
  "@polymer/polymer": "^3.0.0",
44
- "@vaadin/checkbox": "23.0.0-alpha5",
45
- "@vaadin/component-base": "23.0.0-alpha5",
46
- "@vaadin/text-field": "23.0.0-alpha5",
47
- "@vaadin/vaadin-lumo-styles": "23.0.0-alpha5",
48
- "@vaadin/vaadin-material-styles": "23.0.0-alpha5",
49
- "@vaadin/vaadin-themable-mixin": "23.0.0-alpha5"
44
+ "@vaadin/checkbox": "23.0.0-beta1",
45
+ "@vaadin/component-base": "23.0.0-beta1",
46
+ "@vaadin/text-field": "23.0.0-beta1",
47
+ "@vaadin/vaadin-lumo-styles": "23.0.0-beta1",
48
+ "@vaadin/vaadin-material-styles": "23.0.0-beta1",
49
+ "@vaadin/vaadin-themable-mixin": "23.0.0-beta1"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@esm-bundle/chai": "^4.3.4",
53
- "@vaadin/polymer-legacy-adapter": "23.0.0-alpha5",
53
+ "@vaadin/polymer-legacy-adapter": "23.0.0-beta1",
54
54
  "@vaadin/testing-helpers": "^0.3.2",
55
55
  "lit": "^2.0.0",
56
56
  "sinon": "^9.2.0"
57
57
  },
58
- "gitHead": "74f9294964eb8552d96578c14af6ad214f5257bc"
58
+ "gitHead": "467244b76021176c109df675799b07029b293e58"
59
59
  }
@@ -497,7 +497,9 @@ export const ColumnBaseMixin = (superClass) =>
497
497
  }
498
498
 
499
499
  this.__renderCellsContent(headerRenderer, [headerCell]);
500
- this._grid.__updateHeaderFooterRowVisibility(headerCell.parentElement);
500
+ if (this._grid) {
501
+ this._grid.__updateHeaderFooterRowVisibility(headerCell.parentElement);
502
+ }
501
503
  }
502
504
 
503
505
  /** @protected */
@@ -536,7 +538,9 @@ export const ColumnBaseMixin = (superClass) =>
536
538
  }
537
539
 
538
540
  this.__renderCellsContent(footerRenderer, [footerCell]);
539
- this._grid.__updateHeaderFooterRowVisibility(footerCell.parentElement);
541
+ if (this._grid) {
542
+ this._grid.__updateHeaderFooterRowVisibility(footerCell.parentElement);
543
+ }
540
544
  }
541
545
 
542
546
  /** @protected */
@@ -130,6 +130,37 @@ export const KeyboardNavigationMixin = (superClass) =>
130
130
  this._updateGridSectionFocusTarget(this._footerFocusable);
131
131
  }
132
132
 
133
+ /**
134
+ * Since the focused cell/row state is stored as an element reference, the reference may get
135
+ * out of sync when the virtual indexes for elements update due to effective size change.
136
+ * This function updates the reference to the correct element after a possible index change.
137
+ * @private
138
+ */
139
+ __updateItemsFocusable() {
140
+ if (!this._itemsFocusable) {
141
+ return;
142
+ }
143
+
144
+ const wasFocused = this.shadowRoot.activeElement === this._itemsFocusable;
145
+
146
+ this._getVisibleRows().forEach((row) => {
147
+ if (row.index === this._focusedItemIndex) {
148
+ if (this.__rowFocusMode) {
149
+ // Row focus mode
150
+ this._itemsFocusable = row;
151
+ } else if (this._itemsFocusable.parentElement) {
152
+ // Cell focus mode
153
+ const cellIndex = [...this._itemsFocusable.parentElement.children].indexOf(this._itemsFocusable);
154
+ this._itemsFocusable = row.children[cellIndex];
155
+ }
156
+ }
157
+ });
158
+
159
+ if (wasFocused) {
160
+ this._itemsFocusable.focus();
161
+ }
162
+ }
163
+
133
164
  /**
134
165
  * @param {!KeyboardEvent} e
135
166
  * @protected
@@ -531,7 +562,11 @@ export const KeyboardNavigationMixin = (superClass) =>
531
562
 
532
563
  if (this.interacting !== wantInteracting && cell !== null) {
533
564
  if (wantInteracting) {
534
- const focusTarget = cell._content.querySelector('[focus-target]') || cell._content.firstElementChild;
565
+ const focusTarget =
566
+ cell._content.querySelector('[focus-target]') ||
567
+ // If a child element hasn't been explicitly marked as a focus target,
568
+ // fall back to any focusable element inside the cell.
569
+ [...cell._content.querySelectorAll('*')].find((node) => this._isFocusable(node));
535
570
  if (focusTarget) {
536
571
  e.preventDefault();
537
572
  focusTarget.focus();
@@ -805,6 +840,8 @@ export const KeyboardNavigationMixin = (superClass) =>
805
840
  delete this._focusedColumnOrder;
806
841
  this._itemsFocusable = this.__rowFocusMode ? firstVisibleRow : firstVisibleCell;
807
842
  }
843
+ } else {
844
+ this.__updateItemsFocusable();
808
845
  }
809
846
  }
810
847
 
@@ -83,7 +83,9 @@ export const RowDetailsMixin = (superClass) =>
83
83
  Array.from(this.$.items.children).forEach((row) => {
84
84
  if (!row.querySelector('[part~=details-cell]')) {
85
85
  this._updateRow(row, this._columnTree[this._columnTree.length - 1]);
86
- this._a11yUpdateRowDetailsOpened(row, false);
86
+ const isDetailsOpened = this._isDetailsOpened(row._item);
87
+ this._a11yUpdateRowDetailsOpened(row, isDetailsOpened);
88
+ this._toggleDetailsCell(row, isDetailsOpened);
87
89
  }
88
90
  });
89
91
  }
@@ -77,12 +77,8 @@ export const SelectionMixin = (superClass) =>
77
77
  }
78
78
 
79
79
  /** @private */
80
- _selectedItemsChanged(e) {
81
- if (this.$.items.children.length && (e.path === 'selectedItems' || e.path === 'selectedItems.splices')) {
82
- Array.from(this.$.items.children).forEach((row) => {
83
- this._updateItem(row, row._item);
84
- });
85
- }
80
+ _selectedItemsChanged() {
81
+ this.requestContentUpdate();
86
82
  }
87
83
 
88
84
  /**