Skip to content

Commit 24afd2a

Browse files
authored
Removing sticky from table checkboxes to prevent chrome crash (#3504)
1 parent 2f864fb commit 24afd2a

File tree

4 files changed

+29
-9
lines changed

4 files changed

+29
-9
lines changed

packages/@adobe/react-spectrum/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@adobe/react-spectrum",
3-
"version": "3.21.1",
3+
"version": "3.21.2",
44
"description": "Spectrum UI components in React",
55
"license": "Apache-2.0",
66
"main": "dist/main.js",
@@ -53,7 +53,7 @@
5353
"@react-spectrum/slider": "^3.2.1",
5454
"@react-spectrum/statuslight": "^3.4.1",
5555
"@react-spectrum/switch": "^3.3.1",
56-
"@react-spectrum/table": "^3.3.1",
56+
"@react-spectrum/table": "^3.3.2",
5757
"@react-spectrum/tabs": "^3.3.1",
5858
"@react-spectrum/text": "^3.3.1",
5959
"@react-spectrum/textfield": "^3.7.0",

packages/@react-spectrum/table/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@react-spectrum/table",
3-
"version": "3.3.1",
3+
"version": "3.3.2",
44
"description": "Spectrum UI components in React",
55
"license": "Apache-2.0",
66
"main": "dist/main.js",
@@ -49,7 +49,7 @@
4949
"@react-spectrum/utils": "^3.7.3",
5050
"@react-stately/collections": "^3.4.3",
5151
"@react-stately/grid": "^3.3.1",
52-
"@react-stately/layout": "^3.7.0",
52+
"@react-stately/layout": "^3.7.1",
5353
"@react-stately/table": "^3.4.0",
5454
"@react-stately/virtualizer": "^3.3.0",
5555
"@react-types/grid": "^3.1.3",

packages/@react-stately/layout/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@react-stately/layout",
3-
"version": "3.7.0",
3+
"version": "3.7.1",
44
"description": "Spectrum UI components in React",
55
"license": "Apache-2.0",
66
"main": "dist/main.js",

packages/@react-stately/layout/src/TableLayout.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ export class TableLayout<T> extends ListLayout<T> {
2626
isLoading = false;
2727
lastPersistedKeys: Set<Key> = null;
2828
persistedIndices: Map<Key, number[]> = new Map();
29+
private disableSticky: boolean;
2930

3031
constructor(options: ListLayoutOptions<T>) {
3132
super(options);
3233
this.stickyColumnIndices = [];
34+
this.disableSticky = this.checkChrome105();
3335
}
3436

3537

@@ -166,7 +168,7 @@ export class TableLayout<T> extends ListLayout<T> {
166168
let {height, isEstimated} = this.getEstimatedHeight(node, width, this.headingHeight, this.estimatedHeadingHeight);
167169
let rect = new Rect(x, y, width, height);
168170
let layoutInfo = new LayoutInfo(node.type, node.key, rect);
169-
layoutInfo.isSticky = node.props?.isSelectionCell;
171+
layoutInfo.isSticky = !this.disableSticky && node.props?.isSelectionCell;
170172
layoutInfo.zIndex = layoutInfo.isSticky ? 2 : 1;
171173
layoutInfo.estimatedSize = isEstimated;
172174

@@ -195,7 +197,7 @@ export class TableLayout<T> extends ListLayout<T> {
195197
let rect = new Rect(40, Math.max(y, 40), (width || this.virtualizer.visibleRect.width) - 80, children.length === 0 ? this.virtualizer.visibleRect.height - 80 : 60);
196198
let loader = new LayoutInfo('loader', 'loader', rect);
197199
loader.parentKey = 'body';
198-
loader.isSticky = children.length === 0;
200+
loader.isSticky = !this.disableSticky && children.length === 0;
199201
this.layoutInfos.set('loader', loader);
200202
children.push({layoutInfo: loader});
201203
y = loader.rect.maxY;
@@ -204,7 +206,7 @@ export class TableLayout<T> extends ListLayout<T> {
204206
let rect = new Rect(40, Math.max(y, 40), this.virtualizer.visibleRect.width - 80, this.virtualizer.visibleRect.height - 80);
205207
let empty = new LayoutInfo('empty', 'empty', rect);
206208
empty.parentKey = 'body';
207-
empty.isSticky = true;
209+
empty.isSticky = !this.disableSticky;
208210
this.layoutInfos.set('empty', empty);
209211
children.push({layoutInfo: empty});
210212
y = empty.rect.maxY;
@@ -267,7 +269,7 @@ export class TableLayout<T> extends ListLayout<T> {
267269
let {height, isEstimated} = this.getEstimatedHeight(node, width, this.rowHeight, this.estimatedRowHeight);
268270
let rect = new Rect(x, y, width, height);
269271
let layoutInfo = new LayoutInfo(node.type, node.key, rect);
270-
layoutInfo.isSticky = node.props?.isSelectionCell;
272+
layoutInfo.isSticky = !this.disableSticky && node.props?.isSelectionCell;
271273
layoutInfo.zIndex = layoutInfo.isSticky ? 2 : 1;
272274
layoutInfo.estimatedSize = isEstimated;
273275

@@ -440,4 +442,22 @@ export class TableLayout<T> extends ListLayout<T> {
440442

441443
return res;
442444
}
445+
446+
// Checks if Chrome version is 105 or greater
447+
private checkChrome105() {
448+
if (typeof window === 'undefined' || window.navigator == null) {
449+
return false;
450+
}
451+
452+
let isChrome105;
453+
if (window.navigator['userAgentData']) {
454+
isChrome105 = window.navigator['userAgentData']?.brands.some(b => b.brand === 'Chromium' && Number(b.version) >= 105);
455+
} else {
456+
let regex = /Chrome\/(\d+)/;
457+
let matches = regex.exec(window.navigator.userAgent);
458+
isChrome105 = matches && matches.length >= 2 && Number(matches[1]) >= 105;
459+
}
460+
461+
return isChrome105;
462+
}
443463
}

0 commit comments

Comments
 (0)