Skip to content

Commit 935e439

Browse files
committed
Merge branch 's2-combobox-picker-virtualizer' of github.com:adobe/react-spectrum into loadmore_rac
2 parents 1680885 + 3ae8f29 commit 935e439

File tree

17 files changed

+44
-22
lines changed

17 files changed

+44
-22
lines changed

packages/@react-spectrum/autocomplete/test/SearchAutocomplete.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ describe('SearchAutocomplete', function () {
143143
user = userEvent.setup({delay: null, pointerMap});
144144
jest.spyOn(window.HTMLElement.prototype, 'clientWidth', 'get').mockImplementation(() => 1000);
145145
jest.spyOn(window.HTMLElement.prototype, 'clientHeight', 'get').mockImplementation(() => 1000);
146+
jest.spyOn(window.HTMLElement.prototype, 'scrollHeight', 'get').mockImplementation(() => 50);
146147
window.HTMLElement.prototype.scrollIntoView = jest.fn();
147148
simulateDesktop();
148149
jest.useFakeTimers();

packages/@react-spectrum/card/test/CardView.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ describe('CardView', function () {
144144
jest.useFakeTimers();
145145
});
146146

147+
beforeEach(() => {
148+
jest.spyOn(window.HTMLElement.prototype, 'scrollHeight', 'get').mockImplementation(() => 50);
149+
});
150+
147151
afterEach(() => {
148152
jest.clearAllMocks();
149153
act(() => jest.runAllTimers());

packages/@react-spectrum/color/test/ColorPicker.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@ describe('ColorPicker', function () {
2222

2323
beforeAll(() => {
2424
user = userEvent.setup({delay: null, pointerMap});
25+
jest.spyOn(window.HTMLElement.prototype, 'scrollHeight', 'get').mockImplementation(() => 50);
2526
jest.useFakeTimers();
2627
});
2728

29+
afterAll(function () {
30+
jest.restoreAllMocks();
31+
});
32+
2833
afterEach(() => {
2934
act(() => {jest.runAllTimers();});
3035
});

packages/@react-spectrum/combobox/test/ComboBox.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ describe('ComboBox', function () {
257257
});
258258

259259
beforeEach(() => {
260+
jest.spyOn(window.HTMLElement.prototype, 'scrollHeight', 'get').mockImplementation(() => 50);
260261
load = jest
261262
.fn()
262263
.mockImplementationOnce(getFilterItems)

packages/@react-spectrum/picker/test/Picker.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import {User} from '@react-aria/test-utils';
3131
import userEvent from '@testing-library/user-event';
3232

3333
describe('Picker', function () {
34-
let offsetWidth, offsetHeight;
34+
let offsetWidth, offsetHeight, scrollHeight;
3535
let onSelectionChange = jest.fn();
3636
let testUtilUser = new User();
3737
let user;
@@ -40,13 +40,15 @@ describe('Picker', function () {
4040
user = userEvent.setup({delay: null, pointerMap});
4141
offsetWidth = jest.spyOn(window.HTMLElement.prototype, 'clientWidth', 'get').mockImplementation(() => 1000);
4242
offsetHeight = jest.spyOn(window.HTMLElement.prototype, 'clientHeight', 'get').mockImplementation(() => 1000);
43+
scrollHeight = jest.spyOn(window.HTMLElement.prototype, 'scrollHeight', 'get').mockImplementation(() => 50);
4344
simulateDesktop();
4445
jest.useFakeTimers();
4546
});
4647

4748
afterAll(function () {
4849
offsetWidth.mockReset();
4950
offsetHeight.mockReset();
51+
scrollHeight.mockReset();
5052
});
5153

5254
afterEach(() => {

packages/@react-spectrum/picker/test/TempUtilTest.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,14 @@ describe('Picker/Select ', function () {
2727

2828
beforeAll(function () {
2929
user = userEvent.setup({delay: null, pointerMap});
30+
jest.spyOn(window.HTMLElement.prototype, 'scrollHeight', 'get').mockImplementation(() => 50);
3031
simulateDesktop();
3132
});
3233

34+
afterAll(function () {
35+
jest.restoreAllMocks();
36+
});
37+
3338
describe('with real timers', function () {
3439
beforeAll(function () {
3540
jest.useRealTimers();

packages/@react-spectrum/s2/src/ComboBox.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,9 @@ export let listbox = style<{size: 'S' | 'M' | 'L' | 'XL'}>({
207207
width: 'full',
208208
boxSizing: 'border-box',
209209
maxHeight: '[inherit]',
210-
overflow: 'auto',
210+
// TODO: Might help with horizontal scrolling happening on Windows, will need to check somehow. Otherwise, revert back to overflow: auto
211+
overflowY: 'auto',
212+
overflowX: 'hidden',
211213
font: controlFont()
212214
});
213215

@@ -221,7 +223,7 @@ export let listboxItem = style({
221223
value: centerPadding()
222224
},
223225
paddingBottom: '--labelPadding',
224-
backgroundColor: { // TODO: revisit color when I have access to dev mode again
226+
backgroundColor: {
225227
default: 'transparent',
226228
isFocused: baseColor('gray-100').isFocusVisible
227229
},

packages/@react-spectrum/s2/src/Picker.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ export const Picker = /*#__PURE__*/ (forwardRef as forwardRefType)(function Pick
333333
);
334334
}
335335
let scale = useScale();
336+
let layout = new ListLayout({estimatedRowHeight: 32, estimatedHeadingHeight: 50, padding: 8, loaderHeight: LOADER_ROW_HEIGHTS[size][scale]});
336337

337338
return (
338339
<AriaSelect
@@ -413,13 +414,7 @@ export const Picker = /*#__PURE__*/ (forwardRef as forwardRefType)(function Pick
413414
}]
414415
]}>
415416
<Virtualizer
416-
layout={ListLayout}
417-
layoutOptions={{
418-
estimatedRowHeight: 32,
419-
estimatedHeadingHeight: 50,
420-
padding: 8,
421-
loaderHeight: LOADER_ROW_HEIGHTS[size][scale]
422-
}}>
417+
layout={layout}>
423418
<ListBox
424419
items={items}
425420
className={listbox({size})}>

packages/@react-spectrum/s2/src/TableView.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ export class S2TableLayout<T> extends TableLayout<T> {
193193

194194
protected buildCollection(): LayoutNode[] {
195195
let [header, body] = super.buildCollection();
196+
if (!header) {
197+
return [];
198+
}
196199
let {children, layoutInfo} = body;
197200
// TableLayout's buildCollection always sets the body width to the max width between the header width, but
198201
// we want the body to be sticky and only as wide as the table so it is always in view if loading/empty

packages/@react-spectrum/tabs/test/Tabs.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ describe('Tabs', function () {
6060
beforeEach(() => {
6161
jest.spyOn(window.HTMLElement.prototype, 'clientWidth', 'get').mockImplementation(() => 1000);
6262
jest.spyOn(window.HTMLElement.prototype, 'clientHeight', 'get').mockImplementation(() => 1000);
63+
jest.spyOn(window.HTMLElement.prototype, 'scrollHeight', 'get').mockImplementation(() => 50);
6364
window.HTMLElement.prototype.scrollIntoView = jest.fn();
6465
});
6566

0 commit comments

Comments
 (0)