Skip to content

Commit 696565e

Browse files
ritz078LFDanLuToyWalrussnowystingerdevongovett
committed
chore: update upstream code (#6)
* chore: Fix generated code sample for S2 TooltipTrigger docs (adobe#8000) * Fix generated code sample for S2 TooltipTrigger docs * review * inlining * fix: export SortDescriptor type from S2 (adobe#8030) * chore: Deprecate UNSTABLE_portalContainer in favor for PortalProvider (adobe#7976) * Initial refactor to tear out UNSTABLE_portalContainer in favor of the PortalContainer * yarn.lock update * switch to deprecating UNSTABLE_portalContainer * prefer deprecated prop over context to make this a non-breaking change * add rough docs * updating copy to include explaination of UNSTABLE * rename to UNSAFE_PortalProvider * update copy and split out example * use styles from RAC examples --------- Co-authored-by: Robert Snow <[email protected]> * feat: Add escapeKeyBehavior to GridList/ListBox/Menu/Table/Tree (adobe#7974) * Add disallowClearAll to Menu/ListBox so Autocomplete in Popover can close without clearing selection * add support for diallowClearAll to grid/tree/table * make sure RSP components also surface disallowClearAll * update api naming to escapeKeyBehavior * skip 17 tests for build, investigate later * review comments * fix: useMove broken by NODE_ENV check (adobe#8046) * fix: ColorWheel track click (adobe#8049) * fix: minor typo in CalendarDate docs (adobe#8043) * fix: minor typo in CalendarDate docs * fix second example as well --------- Co-authored-by: Robert Snow <[email protected]> * fix: Updating collection when items change parents (adobe#8052) * export Autocomplete from S2 (adobe#8050) * chore: Optimize table test performance (adobe#8051) * chore: Update typescript to 5.8 (adobe#7888) * chore: update typescript to 5.8 * fix all the types for the upgrade * fix numberfield styles * fix: Apply touch-action by default in usePress (adobe#8047) * fix: Apply touch-action by default in usePress * fix test --------- Co-authored-by: Daniel Lu <[email protected]> * fix: set some better flex behaviour (adobe#8048) * fix: Support React 19 and remove Jest reliance in test utils (adobe#7686) * attempt to get rid of jest calls in menu util * update RSP testing docs to directly mention mocks that maybe needed * bump versions of RTL to 16 * use alternative to calling jest run timers in menu option selection * fixing types and properly testing long press * fix lint * revert to pre testing library bump for clean slate * fix build and another submenu edge case now we shouldnt need to call runAllTimers after selectOption * fix react 16 bug * update return type of advanceTimer and docs copy * move some general fixes from selectionMode="replace" branch here * get rid of unneeded async * getting rid of extraneous dep * fix lint * chore: revert ts update (adobe#8060) * fix: add static color to s2 notification badge (adobe#8055) * fix: add static color to s2 notification badge * make opaque * updates * use locale * fix lint --------- Co-authored-by: Robert Snow <[email protected]> * chore: Latest translations (adobe#8036) * Latest translations * Translation correction * Couple of translation corrections * Remove å from Norwegian string --------- Co-authored-by: Yihui Liao <[email protected]> * fix: Relax Parcel version range in public plugins (adobe#8067) * Disclosure button label size update to match new sizes from Specturm (adobe#8006) Co-authored-by: Danni <[email protected]> * chore: audit 3.41 (adobe#8064) * chore: audit 3.41 * remove deprecation * chore: audit 3.41 (adobe#8064) * chore: audit 3.41 * remove deprecation * chore: Update package dependencies for @react-aria/overlays and @react-aria-components * Added @react-aria/ssr and updated @react-aria/overlays in @react-aria/overlays package.json * Added @react-aria/overlays, @react-aria/ssr, and @react-aria/utils in @react-aria-components package.json * chore: Update import paths and dependencies for @react-aria-nutrient * Refactored import statements in various components and tests to use @react-aria-nutrient/overlays instead of @react-aria/overlays. * Removed references to @react-aria/overlays from package.json and yarn.lock. * Updated documentation links to reflect the new package structure. * chore: Update import paths in TableTests to use @react-aria-nutrient * Refactored import statements in TableTests.js to replace @react-aria with @react-aria-nutrient for live-announcer, utils, and focus modules. * Ensured consistency with recent package structure changes. * fix: Add missing newline at end of test files * Ensured proper formatting by adding a newline at the end of Table.test.js and TestTableUtils.test.tsx files to comply with best practices. --------- Co-authored-by: Daniel Lu <[email protected]> Co-authored-by: Trevor Howell <[email protected]> Co-authored-by: Robert Snow <[email protected]> Co-authored-by: Devon Govett <[email protected]> Co-authored-by: DarkstarXDD <[email protected]> Co-authored-by: Robert Snow <[email protected]> Co-authored-by: Reid Barber <[email protected]> Co-authored-by: Yihui Liao <[email protected]> Co-authored-by: Richard Geraghty <[email protected]> Co-authored-by: Kyle Taborski <[email protected]> Co-authored-by: Danni <[email protected]>
1 parent ef401af commit 696565e

27 files changed

+214
-5129
lines changed

packages/@react-aria/overlays/docs/PortalProvider.mdx

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ governing permissions and limitations under the License. */}
1010
import {Layout} from '@react-spectrum/docs';
1111
export default Layout;
1212

13-
import docs from 'docs:@react-aria/overlays';
13+
import docs from 'docs:@react-aria-nutrient/overlays';
1414
import {HeaderInfo, PropTable, FunctionAPI, PageDescription} from '@react-spectrum/docs';
15-
import packageData from '@react-aria/overlays/package.json';
15+
import packageData from '@react-aria-nutrient/overlays/package.json';
1616

1717
---
1818
category: Utilities
@@ -83,7 +83,7 @@ function MyToastRegion() {
8383
```
8484

8585
```tsx example
86-
import {UNSAFE_PortalProvider} from '@react-aria/overlays';
86+
import {UNSAFE_PortalProvider} from '@react-aria-nutrient/overlays';
8787

8888
// See the above Toast docs link for the ToastRegion implementation
8989
function App() {
@@ -128,7 +128,7 @@ used by custom overlay components to ensure that they are also being consistentl
128128
<FunctionAPI links={docs.links} function={docs.exports.useUNSAFE_PortalContext} />
129129

130130
```tsx
131-
import {useUNSAFE_PortalContext} from '@react-aria/overlays';
131+
import {useUNSAFE_PortalContext} from '@react-aria-nutrient/overlays';
132132

133133
function MyOverlay(props) {
134134
let {children} = props;

packages/@react-aria/overlays/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"@react-aria-nutrient/ssr": "^3.9.7",
2929
"@react-aria-nutrient/utils": "^3.28.1",
3030
"@react-aria-nutrient/visually-hidden": "^3.8.21",
31+
"@react-aria/ssr": "^3.9.7",
3132
"@react-stately/overlays": "^3.6.14",
3233
"@react-types/button": "^3.11.0",
3334
"@react-types/overlays": "^3.8.13",

packages/@react-aria/overlays/src/Overlay.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import React, {ReactNode, useContext, useMemo, useState} from 'react';
1616
import ReactDOM from 'react-dom';
1717
import {useIsSSR} from '@react-aria-nutrient/ssr';
1818
import {useLayoutEffect} from '@react-aria-nutrient/utils';
19-
import {useUNSTABLE_PortalContext} from './PortalProvider';
19+
import {useUNSAFE_PortalContext} from './PortalProvider';
2020

2121
export interface OverlayProps {
2222
/**
@@ -55,8 +55,8 @@ export function Overlay(props: OverlayProps): ReactNode | null {
5555
let [contain, setContain] = useState(false);
5656
let contextValue = useMemo(() => ({contain, setContain}), [contain, setContain]);
5757

58-
let {getContainer} = useUNSTABLE_PortalContext();
59-
if (!props.portalContainer && getContainer) {
58+
let {getContainer} = useUNSAFE_PortalContext();
59+
if (!props.portalContainer && getContainer) {
6060
portalContainer = getContainer();
6161
}
6262

packages/@react-aria/overlays/src/useModal.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {DOMAttributes} from '@react-types/shared';
1414
import React, {AriaAttributes, ReactNode, useContext, useEffect, useMemo, useState} from 'react';
1515
import ReactDOM from 'react-dom';
1616
import {useIsSSR} from '@react-aria-nutrient/ssr';
17+
import {useUNSAFE_PortalContext} from './PortalProvider';
1718

1819
export interface ModalProviderProps extends DOMAttributes {
1920
children: ReactNode
@@ -112,6 +113,7 @@ export interface OverlayContainerProps extends ModalProviderProps {
112113
/**
113114
* The container element in which the overlay portal will be placed.
114115
* @default document.body
116+
* @deprecated - Use a parent UNSAFE_PortalProvider to set your portal container instead.
115117
*/
116118
portalContainer?: Element
117119
}
@@ -126,6 +128,10 @@ export interface OverlayContainerProps extends ModalProviderProps {
126128
export function OverlayContainer(props: OverlayContainerProps): React.ReactPortal | null {
127129
let isSSR = useIsSSR();
128130
let {portalContainer = isSSR ? null : document.body, ...rest} = props;
131+
let {getContainer} = useUNSAFE_PortalContext();
132+
if (!props.portalContainer && getContainer) {
133+
portalContainer = getContainer();
134+
}
129135

130136
React.useEffect(() => {
131137
if (portalContainer?.closest('[data-overlay-container]')) {

packages/@react-aria/selection/src/useSelectableItem.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212

1313
import {DOMAttributes, DOMProps, FocusableElement, Key, LongPressEvent, PointerType, PressEvent, RefObject} from '@react-types/shared';
14-
import {focusSafely, PressProps, useLongPress, usePress} from '@react-aria-nutrient/interactions';
14+
import {focusSafely, PressHookProps, useLongPress, usePress} from '@react-aria-nutrient/interactions';
1515
import {getCollectionId, isNonContiguousSelectionModifier} from './utils';
1616
import {isCtrlKeyPressed, mergeProps, openLink, useId, useRouter} from '@react-aria-nutrient/utils';
1717
import {moveVirtualFocus} from '@react-aria-nutrient/focus';
@@ -239,7 +239,7 @@ export function useSelectableItem(options: SelectableItemOptions): SelectableIte
239239
// we want to be able to have the pointer down on the trigger that opens the menu and
240240
// the pointer up on the menu item rather than requiring a separate press.
241241
// For keyboard events, selection still occurs on key down.
242-
let itemPressProps: PressProps = {};
242+
let itemPressProps: PressHookProps = {ref};
243243
if (shouldSelectOnPressUp) {
244244
itemPressProps.onPressStart = (e) => {
245245
modality.current = e.pointerType;

packages/@react-spectrum/dialog/test/DialogContainer.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {Heading, Text} from '@react-spectrum/text';
2121
import {Provider} from '@react-spectrum/provider';
2222
import React, {useRef, useState} from 'react';
2323
import {theme} from '@react-spectrum/theme-default';
24-
import {UNSTABLE_PortalProvider} from '@react-aria-nutrient/overlays';
24+
import {UNSAFE_PortalProvider} from '@react-aria-nutrient/overlays';
2525
import userEvent from '@testing-library/user-event';
2626

2727
describe('DialogContainer', function () {
@@ -254,13 +254,13 @@ describe('DialogContainer', function () {
254254
return (
255255
<Provider theme={theme}>
256256
<ActionButton onPress={() => setOpen(true)}>Open dialog</ActionButton>
257-
<UNSTABLE_PortalProvider getContainer={() => container.current}>
257+
<UNSAFE_PortalProvider getContainer={() => container.current}>
258258
<DialogContainer onDismiss={() => setOpen(false)} {...props}>
259259
{isOpen &&
260260
<ExampleDialog {...props} />
261261
}
262262
</DialogContainer>
263-
</UNSTABLE_PortalProvider>
263+
</UNSAFE_PortalProvider>
264264
<div ref={container} data-testid="custom-container" />
265265
</Provider>
266266
);

packages/@react-spectrum/dialog/test/DialogTrigger.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {Provider} from '@react-spectrum/provider';
2121
import React from 'react';
2222
import {TextField} from '@react-spectrum/textfield';
2323
import {theme} from '@react-spectrum/theme-default';
24-
import {UNSTABLE_PortalProvider} from '@react-aria-nutrient/overlays';
24+
import {UNSAFE_PortalProvider} from '@react-aria-nutrient/overlays';
2525
import userEvent from '@testing-library/user-event';
2626

2727

@@ -1031,12 +1031,12 @@ describe('DialogTrigger', function () {
10311031
let {container} = props;
10321032
return (
10331033
<Provider theme={theme}>
1034-
<UNSTABLE_PortalProvider getContainer={() => container.current}>
1034+
<UNSAFE_PortalProvider getContainer={() => container.current}>
10351035
<DialogTrigger type={props.type}>
10361036
<ActionButton>Trigger</ActionButton>
10371037
<Dialog>contents</Dialog>
10381038
</DialogTrigger>
1039-
</UNSTABLE_PortalProvider>
1039+
</UNSAFE_PortalProvider>
10401040
</Provider>
10411041
);
10421042
}

packages/@react-spectrum/menu/test/MenuTrigger.test.js

+27-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {Link} from '@react-spectrum/link';
2929
import {Provider} from '@react-spectrum/provider';
3030
import React from 'react';
3131
import {theme} from '@react-spectrum/theme-default';
32-
import {UNSTABLE_PortalProvider} from '@react-aria-nutrient/overlays';
32+
import {UNSAFE_PortalProvider} from '@react-aria-nutrient/overlays';
3333
import {User} from '@react-aria-nutrient/test-utils';
3434
import userEvent from '@testing-library/user-event';
3535

@@ -267,6 +267,30 @@ describe('MenuTrigger', function () {
267267
expect(onOpenChange).toBeCalledTimes(1);
268268
});
269269

270+
it.each`
271+
Name | Component | props
272+
${'MenuTrigger'} | ${MenuTrigger} | ${{onOpenChange}}
273+
`('$Name should prevent Esc from clearing selection and close the menu if escapeKeyBehavior is "none"', async function ({Component, props}) {
274+
tree = renderComponent(Component, props, {selectionMode: 'multiple', escapeKeyBehavior: 'none', onSelectionChange});
275+
let menuTester = testUtilUser.createTester('Menu', {root: tree.container, interactionType: 'keyboard'});
276+
expect(onOpenChange).toBeCalledTimes(0);
277+
await menuTester.open();
278+
279+
expect(onOpenChange).toBeCalledTimes(1);
280+
expect(onSelectionChange).toBeCalledTimes(0);
281+
282+
await menuTester.selectOption({option: 'Foo', menuSelectionMode: 'multiple', keyboardActivation: 'Space'});
283+
expect(onSelectionChange).toBeCalledTimes(1);
284+
expect(onSelectionChange.mock.calls[0][0].has('Foo')).toBeTruthy();
285+
await menuTester.selectOption({option: 'Bar', menuSelectionMode: 'multiple', keyboardActivation: 'Space'});
286+
expect(onSelectionChange).toBeCalledTimes(2);
287+
expect(onSelectionChange.mock.calls[1][0].has('Bar')).toBeTruthy();
288+
289+
await menuTester.close();
290+
expect(menuTester.menu).not.toBeInTheDocument();
291+
expect(onOpenChange).toBeCalledTimes(2);
292+
});
293+
270294
it.each`
271295
Name | Component | props | menuProps
272296
${'MenuTrigger multiple'} | ${MenuTrigger} | ${{closeOnSelect: true}} | ${{selectionMode: 'multiple', onClose}}
@@ -735,7 +759,7 @@ describe('MenuTrigger', function () {
735759
function InfoMenu(props) {
736760
return (
737761
<Provider theme={theme}>
738-
<UNSTABLE_PortalProvider getContainer={() => props.container.current}>
762+
<UNSAFE_PortalProvider getContainer={() => props.container.current}>
739763
<MenuTrigger>
740764
<ActionButton aria-label="trigger" />
741765
<Menu>
@@ -744,7 +768,7 @@ describe('MenuTrigger', function () {
744768
<Item key="3">Three</Item>
745769
</Menu>
746770
</MenuTrigger>
747-
</UNSTABLE_PortalProvider>
771+
</UNSAFE_PortalProvider>
748772
</Provider>
749773
);
750774
}

packages/@react-spectrum/table/src/Resizer.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
22
import {classNames} from '@react-spectrum/utils';
33
import {ColumnSize} from '@react-types/table';
44
import eCursor from 'bundle-text:./cursors/Cur_MoveToRight_9_9.svg';
@@ -16,7 +16,7 @@ import {TableColumnResizeState} from '@react-stately/table';
1616
import {useLocale, useLocalizedStringFormatter} from '@react-aria-nutrient/i18n';
1717
import {useTableColumnResize} from '@react-aria-nutrient/table';
1818
import {useTableContext, useVirtualizerContext} from './TableViewBase';
19-
import {useUNSTABLE_PortalContext} from '@react-aria-nutrient/overlays';
19+
import {useUNSAFE_PortalContext} from '@react-aria-nutrient/overlays';
2020
// @ts-ignore
2121
import wCursor from 'bundle-text:./cursors/Cur_MoveToLeft_9_9.svg';
2222

@@ -132,6 +132,6 @@ export const Resizer = React.forwardRef(function Resizer<T>(props: ResizerProps<
132132

133133
function CursorOverlay(props) {
134134
let {show, children} = props;
135-
let {getContainer} = useUNSTABLE_PortalContext();
135+
let {getContainer} = useUNSAFE_PortalContext();
136136
return show ? ReactDOM.createPortal(children, getContainer?.() ?? document.body) : null;
137137
}

packages/@react-spectrum/table/stories/TreeGridTable.stories.tsx

+16-10
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {action} from '@storybook/addon-actions';
1414
import {ActionButton} from '@react-spectrum/button';
1515
import {Cell, Column, Row, SpectrumTableProps, TableBody, TableHeader, TableView} from '../';
1616
import {chain} from '@react-aria-nutrient/utils';
17-
import {ComponentMeta} from '@storybook/react';
17+
import {ComponentMeta, ComponentStoryObj} from '@storybook/react';
1818
import defaultConfig, {columns, EmptyStateTable, TableStory} from './Table.stories';
1919
import {enableTableNestedRows} from '@react-stately/flags';
2020
import {Flex} from '@react-spectrum/layout';
@@ -162,7 +162,6 @@ export const UserSetRowHeader: TableStory = {
162162
}
163163
};
164164

165-
let manyRows: Record<typeof columns[number]['key'], string>[] = [];
166165
function generateRow(lvlIndex, lvlLimit, rowIndex) {
167166
let row = {key: `Row ${rowIndex} Lvl ${lvlIndex}`};
168167
for (let col of columns) {
@@ -175,19 +174,25 @@ function generateRow(lvlIndex, lvlLimit, rowIndex) {
175174
return row;
176175
}
177176

178-
for (let i = 1; i < 20; i++) {
179-
let row = generateRow(1, 3, i);
180-
manyRows.push(row);
177+
function generateRows(count = 5) {
178+
let manyRows: Record<typeof columns[number]['key'], string>[] = [];
179+
for (let i = 1; i <= count; i++) {
180+
let row = generateRow(1, 3, i);
181+
manyRows.push(row);
182+
}
183+
return manyRows;
181184
}
182185

183186
interface ManyExpandableRowsProps extends SpectrumTableProps<unknown> {
184187
allowsResizing?: boolean,
185-
showDivider?: boolean
188+
showDivider?: boolean,
189+
rowCount?: number
186190
}
187191

188192
function ManyExpandableRows(props: ManyExpandableRowsProps) {
189193
let {allowsResizing, showDivider, ...otherProps} = props;
190194
let [expandedKeys, setExpandedKeys] = useState<'all' | Set<Key>>('all');
195+
let manyRows = generateRows(props.rowCount ?? 5);
191196

192197
return (
193198
<Flex direction="column">
@@ -211,11 +216,12 @@ function ManyExpandableRows(props: ManyExpandableRowsProps) {
211216
);
212217
}
213218

214-
export const ManyExpandableRowsStory: TableStory = {
219+
export const ManyExpandableRowsStory: ComponentStoryObj<typeof ManyExpandableRows> = {
215220
args: {
216221
'aria-label': 'TableView with many dynamic expandable rows',
217222
width: 500,
218-
height: 400
223+
height: 400,
224+
rowCount: 5
219225
},
220226
render: (args) => (
221227
<ManyExpandableRows {...args} />
@@ -230,7 +236,7 @@ export const EmptyTreeGridStory: TableStory = {
230236
height: 400
231237
},
232238
render: (args) => (
233-
<EmptyStateTable UNSTABLE_allowsExpandableRows selectionMode="none" columns={columns} items={manyRows} allowsSorting={false} onSortChange={null} sortDescriptor={null} {...args} />
239+
<EmptyStateTable UNSTABLE_allowsExpandableRows selectionMode="none" columns={columns} items={generateRows()} allowsSorting={false} onSortChange={null} sortDescriptor={null} {...args} />
234240
),
235241
name: 'empty state'
236242
};
@@ -245,7 +251,7 @@ function LoadingStateTable(props) {
245251
<TableHeader columns={columns}>
246252
{column => <Column>{column.name}</Column>}
247253
</TableHeader>
248-
<TableBody items={show ? manyRows : []} loadingState="loadingMore">
254+
<TableBody items={show ? generateRows() : []} loadingState="loadingMore">
249255
{item =>
250256
(<Row key={item.key} UNSTABLE_childItems={item.childRows}>
251257
{key => <Cell>{item[key]}</Cell>}

0 commit comments

Comments
 (0)