Skip to content

Commit 1c5aad9

Browse files
ritz078LFDanLuToyWalrussnowystingerdevongovett
authored
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 f336300 commit 1c5aad9

File tree

127 files changed

+6583
-5507
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+6583
-5507
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
"@tailwindcss/postcss": "^4.0.0",
126126
"@testing-library/dom": "^10.1.0",
127127
"@testing-library/jest-dom": "^5.16.5",
128-
"@testing-library/react": "^15.0.7",
128+
"@testing-library/react": "^16.0.0",
129129
"@testing-library/user-event": "patch:@testing-library/user-event@npm%3A14.6.1#~/.yarn/patches/@testing-library-user-event-npm-14.6.1-5da7e1d4e2.patch",
130130
"@types/react": "npm:[email protected]",
131131
"@types/react-dom": "npm:[email protected]",

packages/@internationalized/date/docs/CalendarDate.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ date.toString(); // '2022-02-03'
7272

7373
By default, `CalendarDate` uses the Gregorian calendar system, but many other calendar systems that are used around the world are supported, such as Hebrew, Indian, Islamic, Buddhist, Ethiopic, and more. A <TypeLink links={docs.links} type={docs.exports.Calendar} /> instance can be passed to the `CalendarDate` constructor to represent dates in that calendar system.
7474

75-
This example creates a date in the Buddhist calendar system, which is equivalent to April 4th, 2020 in the Gregorian calendar.
75+
This example creates a date in the Buddhist calendar system, which is equivalent to April 30th, 2020 in the Gregorian calendar.
7676

7777
```tsx
7878
import {BuddhistCalendar} from '@internationalized/date';
@@ -86,7 +86,7 @@ See the [Calendar](Calendar.html#implementations) docs for details about the sup
8686

8787
Many calendar systems have only one era, or a modern era and a pre-modern era (e.g. AD and BC in the Gregorian calendar). However, other calendar systems may have many eras. For example, the Japanese calendar has eras for the reign of each Emperor. `CalendarDate` represents eras using string identifiers, which can be passed as an additional parameter to the constructor before the year. When eras are present, years are numbered starting from 1 within the era.
8888

89-
This example creates a date in the Japanese calendar system, which is equivalent to April 4th, 2020 in the Gregorian calendar.
89+
This example creates a date in the Japanese calendar system, which is equivalent to April 30th, 2019 in the Gregorian calendar.
9090

9191
```tsx
9292
import {JapaneseCalendar} from '@internationalized/date';

packages/@react-aria/collections/src/Document.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,13 @@ export class Document<T, C extends BaseCollection<T> = BaseCollection<T>> extend
460460
}
461461

462462
updateCollection(): void {
463-
// First, update the indices of dirty element children.
463+
// First, remove disconnected nodes and update the indices of dirty element children.
464464
for (let element of this.dirtyNodes) {
465-
element.updateChildIndices();
465+
if (element instanceof ElementNode && (!element.isConnected || element.isHidden)) {
466+
this.removeNode(element);
467+
} else {
468+
element.updateChildIndices();
469+
}
466470
}
467471

468472
// Next, update dirty collection nodes.
@@ -471,8 +475,6 @@ export class Document<T, C extends BaseCollection<T> = BaseCollection<T>> extend
471475
if (element.isConnected && !element.isHidden) {
472476
element.updateNode();
473477
this.addNode(element);
474-
} else {
475-
this.removeNode(element);
476478
}
477479

478480
element.isMutated = false;

packages/@react-aria/grid/src/useGrid.ts

+14-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,16 @@ export interface GridProps extends DOMProps, AriaLabelingProps {
5353
/** Handler that is called when a user performs an action on the row. */
5454
onRowAction?: (key: Key) => void,
5555
/** Handler that is called when a user performs an action on the cell. */
56-
onCellAction?: (key: Key) => void
56+
onCellAction?: (key: Key) => void,
57+
/**
58+
* Whether pressing the escape key should clear selection in the grid or not.
59+
*
60+
* Most experiences should not modify this option as it eliminates a keyboard user's ability to
61+
* easily clear selection. Only use if the escape key is being handled externally or should not
62+
* trigger selection clearing contextually.
63+
* @default 'clearSelection'
64+
*/
65+
escapeKeyBehavior?: 'clearSelection' | 'none'
5766
}
5867

5968
export interface GridAria {
@@ -77,7 +86,8 @@ export function useGrid<T>(props: GridProps, state: GridState<T, GridCollection<
7786
scrollRef,
7887
getRowText,
7988
onRowAction,
80-
onCellAction
89+
onCellAction,
90+
escapeKeyBehavior = 'clearSelection'
8191
} = props;
8292
let {selectionManager: manager} = state;
8393

@@ -106,7 +116,8 @@ export function useGrid<T>(props: GridProps, state: GridState<T, GridCollection<
106116
keyboardDelegate: delegate,
107117
isVirtualized,
108118
scrollRef,
109-
disallowTypeAhead
119+
disallowTypeAhead,
120+
escapeKeyBehavior
110121
});
111122

112123
let id = useId(props.id);

packages/@react-aria/gridlist/src/useGridList.ts

+14-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,16 @@ export interface AriaGridListProps<T> extends GridListProps<T>, DOMProps, AriaLa
4848
* via the left/right arrow keys or the tab key.
4949
* @default 'arrow'
5050
*/
51-
keyboardNavigationBehavior?: 'arrow' | 'tab'
51+
keyboardNavigationBehavior?: 'arrow' | 'tab',
52+
/**
53+
* Whether pressing the escape key should clear selection in the grid list or not.
54+
*
55+
* Most experiences should not modify this option as it eliminates a keyboard user's ability to
56+
* easily clear selection. Only use if the escape key is being handled externally or should not
57+
* trigger selection clearing contextually.
58+
* @default 'clearSelection'
59+
*/
60+
escapeKeyBehavior?: 'clearSelection' | 'none'
5261
}
5362

5463
export interface AriaGridListOptions<T> extends Omit<AriaGridListProps<T>, 'children'> {
@@ -105,7 +114,8 @@ export function useGridList<T>(props: AriaGridListOptions<T>, state: ListState<T
105114
onAction,
106115
disallowTypeAhead,
107116
linkBehavior = 'action',
108-
keyboardNavigationBehavior = 'arrow'
117+
keyboardNavigationBehavior = 'arrow',
118+
escapeKeyBehavior = 'clearSelection'
109119
} = props;
110120

111121
if (!props['aria-label'] && !props['aria-labelledby']) {
@@ -124,7 +134,8 @@ export function useGridList<T>(props: AriaGridListOptions<T>, state: ListState<T
124134
shouldFocusWrap: props.shouldFocusWrap,
125135
linkBehavior,
126136
disallowTypeAhead,
127-
autoFocus: props.autoFocus
137+
autoFocus: props.autoFocus,
138+
escapeKeyBehavior
128139
});
129140

130141
let id = useId(props.id);

packages/@react-aria/interactions/src/useMove.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export function useMove(props: MoveEvents): MoveResult {
9393
state.current.didMove = false;
9494
};
9595

96-
if (typeof PointerEvent === 'undefined') {
96+
if (typeof PointerEvent === 'undefined' && process.env.NODE_ENV === 'test') {
9797
let onMouseMove = (e: MouseEvent) => {
9898
if (e.button === 0) {
9999
move(e, 'mouse', e.pageX - (state.current.lastPosition?.pageX ?? 0), e.pageY - (state.current.lastPosition?.pageY ?? 0));
@@ -151,7 +151,7 @@ export function useMove(props: MoveEvents): MoveResult {
151151
addGlobalListener(window, 'touchend', onTouchEnd, false);
152152
addGlobalListener(window, 'touchcancel', onTouchEnd, false);
153153
};
154-
} else if (process.env.NODE_ENV === 'test') {
154+
} else {
155155
let onPointerMove = (e: PointerEvent) => {
156156
if (e.pointerId === state.current.id) {
157157
let pointerType = (e.pointerType || 'mouse') as PointerType;

packages/@react-aria/interactions/src/usePress.ts

+16-4
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,7 @@ export function usePress(props: PressHookProps): PressResult {
176176
preventFocusOnPress,
177177
shouldCancelOnPointerExit,
178178
allowTextSelectionOnPress,
179-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
180-
ref: _, // Removing `ref` from `domProps` because TypeScript is dumb
179+
ref: domRef,
181180
...domProps
182181
} = usePressResponderContext(props);
183182

@@ -814,13 +813,26 @@ export function usePress(props: PressHookProps): PressResult {
814813
triggerSyntheticClick
815814
]);
816815

817-
// Remove user-select: none in case component unmounts immediately after pressStart
816+
// Avoid onClick delay for double tap to zoom by default.
817+
useEffect(() => {
818+
let element = domRef?.current;
819+
if (element && (element instanceof getOwnerWindow(element).Element)) {
820+
// Only apply touch-action if not already set by another CSS rule.
821+
let style = getOwnerWindow(element).getComputedStyle(element);
822+
if (style.touchAction === 'auto') {
823+
// touchAction: 'manipulation' is supposed to be equivalent, but in
824+
// Safari it causes onPointerCancel not to fire on scroll.
825+
// https://bugs.webkit.org/show_bug.cgi?id=240917
826+
(element as HTMLElement).style.touchAction = 'pan-x pan-y pinch-zoom';
827+
}
828+
}
829+
}, [domRef]);
818830

831+
// Remove user-select: none in case component unmounts immediately after pressStart
819832
useEffect(() => {
820833
let state = ref.current;
821834
return () => {
822835
if (!allowTextSelectionOnPress) {
823-
824836
restoreTextSelection(state.target ?? undefined);
825837
}
826838
for (let dispose of state.disposables) {

packages/@react-aria/interactions/stories/usePress.stories.tsx

+68-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
Modal,
2020
ModalOverlay
2121
} from 'react-aria-components';
22-
import React from 'react';
22+
import React, {useState} from 'react';
2323
import styles from './usePress-stories.css';
2424
import {usePress} from '@react-aria-nutrient/interactions';
2525

@@ -234,3 +234,70 @@ export function SoftwareKeyboardIssue() {
234234
</div>
235235
);
236236
}
237+
238+
export function AndroidUnmountIssue() {
239+
let [showButton, setShowButton] = useState(true);
240+
241+
return (
242+
<div style={{display: 'flex', flexDirection: 'column', alignItems: 'center'}}>
243+
<p>This story tests an Android issue where tapping a button that unmounts causes the element behind it to receive onClick.</p>
244+
<div style={{position: 'relative', width: 100, height: 100}}>
245+
<button
246+
type="button"
247+
onClick={() => {
248+
alert('button underneath was pressed');
249+
}}
250+
style={{position: 'absolute', top: 0}}>
251+
Test 2
252+
</button>
253+
{showButton && (
254+
<Button
255+
className="foo"
256+
style={{position: 'absolute', top: 0}}
257+
onPress={() => {
258+
console.log('ra Button pressed');
259+
setShowButton(false);
260+
}}>
261+
Test
262+
</Button>
263+
)}
264+
</div>
265+
</div>
266+
);
267+
}
268+
269+
export function IOSScrollIssue() {
270+
return (
271+
<div style={{display: 'flex', flexDirection: 'column', alignItems: 'center'}}>
272+
<p>This story tests an iOS Safari issue that causes onPointerCancel not to be fired with touch-action: manipulation. Scrolling the list should not trigger onPress.</p>
273+
<div
274+
style={{
275+
marginTop: 10,
276+
width: 500,
277+
height: 100,
278+
overflowY: 'hidden',
279+
overflowX: 'auto',
280+
border: '1px solid black',
281+
display: 'flex',
282+
gap: 8
283+
}}>
284+
{Array.from({length: 10}).map((_, i) => (
285+
<Card key={i} />
286+
))}
287+
</div>
288+
</div>
289+
);
290+
}
291+
292+
function Card() {
293+
return (
294+
<Button
295+
className="foo"
296+
style={{height: 80, width: 150, flexShrink: 0}}
297+
onPress={() => {
298+
alert('pressed');
299+
}}>
300+
Test
301+
</Button>
302+
);
303+
}

0 commit comments

Comments
 (0)