Skip to content

Commit a4f35b1

Browse files
authored
Merge branch 'main' into shadow-dom-enhancement-1-getRootNode
2 parents 5bf5bb7 + 3e1c518 commit a4f35b1

27 files changed

Lines changed: 190 additions & 67 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
"@testing-library/dom": "^10.1.0",
126126
"@testing-library/jest-dom": "^5.16.5",
127127
"@testing-library/react": "^15.0.7",
128-
"@testing-library/user-event": "^14.5.2",
128+
"@testing-library/user-event": "^14.6.1",
129129
"@types/react": "npm:types-react@19.0.0-rc.0",
130130
"@types/react-dom": "npm:types-react-dom@19.0.0-rc.0",
131131
"@types/storybook__react": "^4.0.2",

packages/@react-aria/button/src/useButton.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ export function useButton(props: AriaButtonOptions<ElementType>, ref: RefObject<
107107
'aria-expanded': props['aria-expanded'],
108108
'aria-controls': props['aria-controls'],
109109
'aria-pressed': props['aria-pressed'],
110+
'aria-current': props['aria-current'],
110111
onClick: (e) => {
111112
if (deprecatedOnClick) {
112113
deprecatedOnClick(e);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"@react-aria/utils": "^3.27.0",
2727
"@react-types/shared": "^3.27.0",
2828
"@swc/helpers": "^0.5.0",
29-
"use-sync-external-store": "^1.2.0"
29+
"use-sync-external-store": "^1.4.0"
3030
},
3131
"peerDependencies": {
3232
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",

packages/@react-aria/dnd/test/dnd.test.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2306,7 +2306,7 @@ describe('useDrag and useDrop', function () {
23062306
expect(document.getElementById(draggable.getAttribute('aria-describedby'))).toHaveTextContent('Click to start dragging');
23072307
expect(draggable).toHaveAttribute('data-dragging', 'false');
23082308

2309-
await user.click(draggable);
2309+
await user.pointer({target: draggable, keys: '[MouseLeft]', coords: {width: 0, height: 0}});
23102310
act(() => jest.runAllTimers());
23112311
expect(document.activeElement).toBe(draggable);
23122312
expect(draggable).toHaveAttribute('aria-describedby');
@@ -2425,7 +2425,7 @@ describe('useDrag and useDrop', function () {
24252425
let buttons = tree.getAllByRole('button');
24262426
expect(buttons).toHaveLength(4);
24272427

2428-
await user.click(draggable);
2428+
await user.pointer({target: draggable, keys: '[MouseLeft]', coords: {width: 0, height: 0}});
24292429
act(() => jest.runAllTimers());
24302430

24312431
buttons = tree.getAllByRole('button');
@@ -2469,7 +2469,7 @@ describe('useDrag and useDrop', function () {
24692469
act(() => draggable.focus());
24702470
fireEvent(draggable, pointerEvent('pointerdown', {pointerId: 1, width: 1, height: 1, pressure: 0, detail: 0}));
24712471
fireEvent(draggable, pointerEvent('pointerup', {pointerId: 1, width: 1, height: 1, pressure: 0, detail: 0}));
2472-
await user.click(draggable);
2472+
await user.pointer({target: draggable, keys: '[MouseLeft]', coords: {width: 0, height: 0}});
24732473
act(() => jest.runAllTimers());
24742474
expect(draggable).toHaveAttribute('data-dragging', 'true');
24752475
expect(draggable).toHaveAttribute('aria-describedby');
@@ -2499,7 +2499,7 @@ describe('useDrag and useDrop', function () {
24992499
act(() => draggable.focus());
25002500
fireEvent(draggable, pointerEvent('pointerdown', {pointerId: 1, width: 1, height: 1, pressure: 0, detail: 0}));
25012501
fireEvent(draggable, pointerEvent('pointerup', {pointerId: 1, width: 1, height: 1, pressure: 0, detail: 0}));
2502-
await user.click(draggable);
2502+
await user.pointer({target: draggable, keys: '[MouseLeft]', coords: {width: 0, height: 0}});
25032503
act(() => jest.runAllTimers());
25042504
expect(draggable).toHaveAttribute('data-dragging', 'true');
25052505

@@ -2536,7 +2536,7 @@ describe('useDrag and useDrop', function () {
25362536
let draggable = tree.getByText('Drag me');
25372537

25382538
act(() => draggable.focus());
2539-
await user.click(draggable);
2539+
await user.pointer({target: draggable, keys: '[MouseLeft]', coords: {width: 0, height: 0}});
25402540
act(() => jest.runAllTimers());
25412541

25422542
expect(tree.getAllByRole('button')).toHaveLength(2);
@@ -2597,7 +2597,7 @@ describe('useDrag and useDrop', function () {
25972597
let draggable = tree.getByText('Drag me');
25982598

25992599
act(() => draggable.focus());
2600-
await user.click(draggable);
2600+
await user.pointer({target: draggable, keys: '[MouseLeft]', coords: {width: 0, height: 0}});
26012601
act(() => jest.runAllTimers());
26022602

26032603
expect(tree.getAllByRole('button')).toHaveLength(3);
@@ -2622,7 +2622,7 @@ describe('useDrag and useDrop', function () {
26222622
let draggable = tree.getByText('Drag me');
26232623

26242624
act(() => draggable.focus());
2625-
await user.click(draggable);
2625+
await user.pointer({target: draggable, keys: '[MouseLeft]', coords: {width: 0, height: 0}});
26262626
act(() => jest.runAllTimers());
26272627

26282628
expect(tree.getAllByRole('button')).toHaveLength(3);
@@ -2645,7 +2645,7 @@ describe('useDrag and useDrop', function () {
26452645
let input = tree.getByRole('textbox');
26462646

26472647
act(() => draggable.focus());
2648-
await user.click(draggable);
2648+
await user.pointer({target: draggable, keys: '[MouseLeft]', coords: {width: 0, height: 0}});
26492649
act(() => jest.runAllTimers());
26502650

26512651
act(() => droppable.focus());
@@ -2665,7 +2665,7 @@ describe('useDrag and useDrop', function () {
26652665
let input = tree.getByRole('textbox');
26662666

26672667
act(() => draggable.focus());
2668-
await user.click(draggable);
2668+
await user.pointer({target: draggable, keys: '[MouseLeft]', coords: {width: 0, height: 0}});
26692669
act(() => jest.runAllTimers());
26702670

26712671
act(() => input.focus());
@@ -2682,7 +2682,7 @@ describe('useDrag and useDrop', function () {
26822682
let droppable = tree.getByText('Drop here');
26832683

26842684
act(() => draggable.focus());
2685-
await user.click(draggable);
2685+
await user.pointer({target: draggable, keys: '[MouseLeft]', coords: {width: 0, height: 0}});
26862686
act(() => jest.runAllTimers());
26872687

26882688
act(() => droppable.focus());
@@ -2700,7 +2700,7 @@ describe('useDrag and useDrop', function () {
27002700
let draggable = tree.getByText('Drag me');
27012701

27022702
act(() => draggable.focus());
2703-
await user.click(draggable);
2703+
await user.pointer({target: draggable, keys: '[MouseLeft]', coords: {width: 0, height: 0}});
27042704
act(() => jest.runAllTimers());
27052705

27062706
act(() => draggable.blur());
@@ -2732,7 +2732,7 @@ describe('useDrag and useDrop', function () {
27322732
let droppable = tree.getByText('Drop here');
27332733

27342734
act(() => draggable.focus());
2735-
await user.click(draggable);
2735+
await user.pointer({target: draggable, keys: '[MouseLeft]', coords: {width: 0, height: 0}});
27362736
act(() => jest.runAllTimers());
27372737
expect(draggable).toHaveAttribute('data-dragging', 'true');
27382738

@@ -2757,7 +2757,7 @@ describe('useDrag and useDrop', function () {
27572757
expect(draggable).toHaveAttribute('aria-describedby');
27582758
expect(document.getElementById(draggable.getAttribute('aria-describedby'))).toHaveTextContent('Double tap to start dragging');
27592759

2760-
await user.click(draggable);
2760+
await user.pointer({target: draggable, keys: '[MouseLeft]', coords: {width: 0, height: 0}});
27612761
act(() => jest.runAllTimers());
27622762
expect(document.activeElement).toBe(draggable);
27632763
expect(draggable).toHaveAttribute('aria-describedby');

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,15 +290,18 @@ const nonTextInputTypes = new Set([
290290
* focus visible style can be properly set.
291291
*/
292292
function isKeyboardFocusEvent(isTextInput: boolean, modality: Modality, e: HandlerEvent) {
293+
let document = getOwnerDocument(e?.target as Element);
293294
const IHTMLInputElement = typeof window !== 'undefined' ? getOwnerWindow(e?.target as Element).HTMLInputElement : HTMLInputElement;
294295
const IHTMLTextAreaElement = typeof window !== 'undefined' ? getOwnerWindow(e?.target as Element).HTMLTextAreaElement : HTMLTextAreaElement;
295296
const IHTMLElement = typeof window !== 'undefined' ? getOwnerWindow(e?.target as Element).HTMLElement : HTMLElement;
296297
const IKeyboardEvent = typeof window !== 'undefined' ? getOwnerWindow(e?.target as Element).KeyboardEvent : KeyboardEvent;
297298

299+
// For keyboard events that occur on a non-input element that will move focus into input element (aka ArrowLeft going from Datepicker button to the main input group)
300+
// we need to rely on the user passing isTextInput into here. This way we can skip toggling focus visiblity for said input element
298301
isTextInput = isTextInput ||
299-
(e?.target instanceof IHTMLInputElement && !nonTextInputTypes.has(e?.target?.type)) ||
300-
e?.target instanceof IHTMLTextAreaElement ||
301-
(e?.target instanceof IHTMLElement && e?.target.isContentEditable);
302+
(document.activeElement instanceof IHTMLInputElement && !nonTextInputTypes.has(document.activeElement.type)) ||
303+
document.activeElement instanceof IHTMLTextAreaElement ||
304+
(document.activeElement instanceof IHTMLElement && document.activeElement.isContentEditable);
302305
return !(isTextInput && modality === 'keyboard' && e instanceof IKeyboardEvent && !FOCUS_VISIBLE_INPUT_KEYS[e.key]);
303306
}
304307

@@ -323,6 +326,7 @@ export function useFocusVisibleListener(fn: FocusVisibleHandler, deps: ReadonlyA
323326

324327
useEffect(() => {
325328
let handler = (modality: Modality, e: HandlerEvent) => {
329+
// We want to early return for any keyboard events that occur inside text inputs EXCEPT for Tab and Escape
326330
if (!isKeyboardFocusEvent(!!(opts?.isTextInput), modality, e)) {
327331
return;
328332
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"@react-aria/utils": "^3.27.0",
2626
"@react-types/shared": "^3.27.0",
2727
"@swc/helpers": "^0.5.0",
28-
"use-sync-external-store": "^1.2.0"
28+
"use-sync-external-store": "^1.4.0"
2929
},
3030
"peerDependencies": {
3131
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",

packages/@react-aria/menu/src/useMenuItem.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ export interface MenuItemAria {
3434

3535
/** Whether the item is currently focused. */
3636
isFocused: boolean,
37+
/** Whether the item is keyboard focused. */
38+
isFocusVisible: boolean,
3739
/** Whether the item is currently selected. */
3840
isSelected: boolean,
3941
/** Whether the item is currently in a pressed state. */
@@ -316,6 +318,7 @@ export function useMenuItem<T>(props: AriaMenuItemProps, state: TreeState<T>, re
316318
id: keyboardId
317319
},
318320
isFocused,
321+
isFocusVisible: isFocused && isFocusVisible(),
319322
isSelected,
320323
isPressed,
321324
isDisabled

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"@swc/helpers": "^0.5.0"
2929
},
3030
"peerDependencies": {
31-
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
31+
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
32+
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
3233
},
3334
"publishConfig": {
3435
"access": "public"

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"@swc/helpers": "^0.5.0"
3030
},
3131
"peerDependencies": {
32-
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
32+
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
33+
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
3334
},
3435
"publishConfig": {
3536
"access": "public"

packages/@react-aria/test-utils/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"peerDependencies": {
2828
"@testing-library/react": "^15.0.7",
29-
"@testing-library/user-event": "^13.0.0 || ^14.0.0",
29+
"@testing-library/user-event": "^14.0.0",
3030
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
3131
},
3232
"publishConfig": {

0 commit comments

Comments
 (0)