Skip to content

Commit 3dee094

Browse files
committed
Merge branch 'main' of github.com:adobe/react-spectrum into subdialogs
# Conflicts: # packages/@react-aria/focus/src/index.ts # packages/@react-aria/selection/src/useSelectableCollection.ts # packages/@react-aria/selection/src/useSelectableItem.ts # packages/react-aria-components/test/Menu.test.tsx
2 parents 7be3d10 + 7196e39 commit 3dee094

File tree

207 files changed

+1963
-421
lines changed

Some content is hidden

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

207 files changed

+1963
-421
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"url": "https://github.com/adobe/react-spectrum"
2323
},
2424
"dependencies": {
25-
"@react-aria/focus": "^3.19.1",
2625
"@react-aria/interactions": "^3.23.0",
2726
"@react-aria/toolbar": "3.0.0-beta.12",
2827
"@react-aria/utils": "^3.27.0",

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ import {
2121
import {AriaButtonProps} from '@react-types/button';
2222
import {DOMAttributes} from '@react-types/shared';
2323
import {filterDOMProps, mergeProps} from '@react-aria/utils';
24-
import {useFocusable} from '@react-aria/focus';
25-
import {usePress} from '@react-aria/interactions';
24+
import {useFocusable, usePress} from '@react-aria/interactions';
2625

2726
export interface AriaButtonOptions<E extends ElementType> extends Omit<AriaButtonProps<E>, 'children'> {}
2827

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
2727
},
2828
"dependencies": {
29-
"@react-aria/focus": "^3.19.1",
29+
"@react-aria/interactions": "^3.23.0",
3030
"@react-aria/overlays": "^3.25.0",
3131
"@react-aria/utils": "^3.27.0",
3232
"@react-types/dialog": "^3.5.15",

packages/@react-aria/dialog/src/useDialog.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import {AriaDialogProps} from '@react-types/dialog';
1414
import {DOMAttributes, FocusableElement, RefObject} from '@react-types/shared';
1515
import {filterDOMProps, useSlotId} from '@react-aria/utils';
16-
import {focusSafely} from '@react-aria/focus';
16+
import {focusSafely} from '@react-aria/interactions';
1717
import {useEffect, useRef} from 'react';
1818
import {useOverlayFocusContain} from '@react-aria/overlays';
1919

packages/@react-aria/focus/src/FocusScope.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ import {
2323
useLayoutEffect
2424
} from '@react-aria/utils';
2525
import {FocusableElement, RefObject} from '@react-types/shared';
26-
import {focusSafely} from './focusSafely';
27-
import {getInteractionModality} from '@react-aria/interactions';
26+
import {focusSafely, getInteractionModality} from '@react-aria/interactions';
2827
import {isElementVisible} from './isElementVisible';
2928
import React, {ReactNode, useContext, useEffect, useMemo, useRef} from 'react';
3029

packages/@react-aria/focus/src/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@
1212

1313
export {FocusScope, useFocusManager, getFocusableTreeWalker, createFocusManager, isElementInChildOfActiveScope} from './FocusScope';
1414
export {FocusRing} from './FocusRing';
15-
export {FocusableProvider, useFocusable} from './useFocusable';
1615
export {useFocusRing} from './useFocusRing';
17-
export {focusSafely} from './focusSafely';
1816
export {useHasTabbableChild} from './useHasTabbableChild';
17+
export {moveVirtualFocus, dispatchVirtualBlur, dispatchVirtualFocus, getVirtuallyFocusedElement} from './virtualFocus';
1918
// For backward compatibility.
2019
export {isFocusable} from '@react-aria/utils';
21-
export {moveVirtualFocus, dispatchVirtualBlur, dispatchVirtualFocus, getVirtuallyFocusedElement} from './virtualFocus';
20+
export {FocusableProvider, Focusable, useFocusable, focusSafely} from '@react-aria/interactions';
2221

2322
export type {FocusScopeProps, FocusManager, FocusManagerOptions} from './FocusScope';
2423
export type {FocusRingProps} from './FocusRing';
25-
export type {FocusableAria, FocusableOptions, FocusableProviderProps} from './useFocusable';
24+
export type {FocusableAria, FocusableOptions, FocusableProviderProps} from '@react-aria/interactions';
2625
export type {AriaFocusRingProps, FocusRingAria} from './useFocusRing';

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

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import {Direction, DisabledBehavior, Key, KeyboardDelegate, LayoutDelegate, Node, Rect, RefObject, Size} from '@react-types/shared';
1414
import {DOMLayoutDelegate} from '@react-aria/selection';
1515
import {getChildNodes, getFirstItem, getLastItem, getNthItem} from '@react-stately/collections';
16-
import {GridCollection} from '@react-types/grid';
16+
import {GridCollection, GridNode} from '@react-types/grid';
1717

1818
export interface GridKeyboardDelegateOptions<C> {
1919
collection: C,
@@ -103,6 +103,35 @@ export class GridKeyboardDelegate<T, C extends GridCollection<T>> implements Key
103103
return null;
104104
}
105105

106+
protected getKeyForItemInRowByIndex(key: Key, index: number = 0): Key | null {
107+
if (index < 0) {
108+
return null;
109+
}
110+
111+
let item = this.collection.getItem(key);
112+
if (!item) {
113+
return null;
114+
}
115+
116+
let i = 0;
117+
for (let child of getChildNodes(item, this.collection) as Iterable<GridNode<T>>) {
118+
if (child.colSpan && child.colSpan + i > index) {
119+
return child.key ?? null;
120+
}
121+
122+
if (child.colSpan) {
123+
i = i + child.colSpan - 1;
124+
}
125+
126+
if (i === index) {
127+
return child.key ?? null;
128+
}
129+
130+
i++;
131+
}
132+
return null;
133+
}
134+
106135
getKeyBelow(fromKey: Key) {
107136
let key: Key | null = fromKey;
108137
let startItem = this.collection.getItem(key);
@@ -123,11 +152,8 @@ export class GridKeyboardDelegate<T, C extends GridCollection<T>> implements Key
123152
if (key != null) {
124153
// If focus was on a cell, focus the cell with the same index in the next row.
125154
if (this.isCell(startItem)) {
126-
let item = this.collection.getItem(key);
127-
if (!item) {
128-
return null;
129-
}
130-
return getNthItem(getChildNodes(item, this.collection), startItem.index ?? 0)?.key ?? null;
155+
let startIndex = startItem.colIndex ? startItem.colIndex : startItem.index;
156+
return this.getKeyForItemInRowByIndex(key, startIndex);
131157
}
132158

133159
// Otherwise, focus the next row
@@ -158,11 +184,8 @@ export class GridKeyboardDelegate<T, C extends GridCollection<T>> implements Key
158184
if (key != null) {
159185
// If focus was on a cell, focus the cell with the same index in the previous row.
160186
if (this.isCell(startItem)) {
161-
let item = this.collection.getItem(key);
162-
if (!item) {
163-
return null;
164-
}
165-
return getNthItem(getChildNodes(item, this.collection), startItem.index ?? 0)?.key || null;
187+
let startIndex = startItem.colIndex ? startItem.colIndex : startItem.index;
188+
return this.getKeyForItemInRowByIndex(key, startIndex);
166189
}
167190

168191
// Otherwise, focus the previous row

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
*/
1212

1313
import {DOMAttributes, FocusableElement, Key, RefObject} from '@react-types/shared';
14-
import {focusSafely, getFocusableTreeWalker} from '@react-aria/focus';
14+
import {focusSafely, isFocusVisible} from '@react-aria/interactions';
15+
import {getFocusableTreeWalker} from '@react-aria/focus';
1516
import {getScrollParent, mergeProps, scrollIntoViewport} from '@react-aria/utils';
1617
import {GridCollection, GridNode} from '@react-types/grid';
1718
import {gridMap} from './utils';
1819
import {GridState} from '@react-stately/grid';
19-
import {isFocusVisible} from '@react-aria/interactions';
2020
import {KeyboardEvent as ReactKeyboardEvent, useRef} from 'react';
2121
import {useLocale} from '@react-aria/i18n';
2222
import {useSelectableItem} from '@react-aria/selection';
@@ -30,6 +30,8 @@ export interface GridCellProps {
3030
focusMode?: 'child' | 'cell',
3131
/** Whether selection should occur on press up instead of press down. */
3232
shouldSelectOnPressUp?: boolean,
33+
/** Indicates how many columns the data cell spans. */
34+
colSpan?: number,
3335
/**
3436
* Handler that is called when a user performs an action on the cell.
3537
* Please use onCellAction at the collection level instead.
@@ -251,6 +253,9 @@ export function useGridCell<T, C extends GridCollection<T>>(props: GridCellProps
251253
let gridCellProps: DOMAttributes = mergeProps(itemProps, {
252254
role: 'gridcell',
253255
onKeyDownCapture,
256+
'aria-colspan': node.colSpan,
257+
'aria-colindex': node.colIndex != null ? node.colIndex + 1 : undefined, // aria-colindex is 1-based
258+
colSpan: isVirtualized ? undefined : node.colSpan,
254259
onFocus
255260
});
256261

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

Lines changed: 0 additions & 39 deletions
This file was deleted.

packages/@react-aria/interactions/src/DOMPropsResponder.tsx

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)