Skip to content

Commit d18d362

Browse files
authored
Merge branch 'main' into rac-toast
2 parents 8634c78 + 060be36 commit d18d362

39 files changed

+1133
-724
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"url": "https://github.com/adobe/react-spectrum"
2323
},
2424
"dependencies": {
25+
"@react-aria/interactions": "^3.23.0",
2526
"@react-aria/ssr": "^3.9.7",
2627
"@react-aria/utils": "^3.27.0",
2728
"@react-types/shared": "^3.27.0",

packages/@react-aria/collections/src/CollectionBuilder.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {BaseCollection} from './BaseCollection';
1414
import {BaseNode, Document, ElementNode} from './Document';
1515
import {CachedChildrenOptions, useCachedChildren} from './useCachedChildren';
1616
import {createPortal} from 'react-dom';
17+
import {FocusableContext} from '@react-aria/interactions';
1718
import {forwardRefType, Node} from '@react-types/shared';
1819
import {Hidden} from './Hidden';
1920
import React, {createContext, ForwardedRef, forwardRef, JSX, ReactElement, ReactNode, useCallback, useContext, useMemo, useRef, useState} from 'react';
@@ -161,6 +162,7 @@ export function createLeafComponent<T extends object, P extends object, E extend
161162
export function createLeafComponent<P extends object, E extends Element>(type: string, render: (props: P, ref: ForwardedRef<E>, node?: any) => ReactElement) {
162163
let Component = ({node}) => render(node.props, node.props.ref, node);
163164
let Result = (forwardRef as forwardRefType)((props: P, ref: ForwardedRef<E>) => {
165+
let focusableProps = useContext(FocusableContext);
164166
let isShallow = useContext(ShallowRenderContext);
165167
if (!isShallow) {
166168
if (render.length >= 3) {
@@ -169,7 +171,19 @@ export function createLeafComponent<P extends object, E extends Element>(type: s
169171
return render(props, ref);
170172
}
171173

172-
return useSSRCollectionNode(type, props, ref, 'children' in props ? props.children : null, null, node => <Component node={node} />);
174+
return useSSRCollectionNode(
175+
type,
176+
props,
177+
ref,
178+
'children' in props ? props.children : null,
179+
null,
180+
node => (
181+
// Forward FocusableContext to real DOM tree so tooltips work.
182+
<FocusableContext.Provider value={focusableProps}>
183+
<Component node={node} />
184+
</FocusableContext.Provider>
185+
)
186+
);
173187
});
174188
// @ts-ignore
175189
Result.displayName = render.name;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export {useMove} from './useMove';
3030
export {usePress} from './usePress';
3131
export {useScrollWheel} from './useScrollWheel';
3232
export {useLongPress} from './useLongPress';
33-
export {useFocusable, FocusableProvider, Focusable} from './useFocusable';
33+
export {useFocusable, FocusableProvider, Focusable, FocusableContext} from './useFocusable';
3434
export {focusSafely} from './focusSafely';
3535

3636
export type {FocusProps, FocusResult} from './useFocus';

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ interface FocusableContextValue extends FocusableProviderProps {
3131
ref?: MutableRefObject<FocusableElement | null>
3232
}
3333

34-
let FocusableContext = React.createContext<FocusableContextValue | null>(null);
34+
// Exported for @react-aria/collections, which forwards this context.
35+
/** @private */
36+
export let FocusableContext = React.createContext<FocusableContextValue | null>(null);
3537

3638
function useFocusableContext(ref: RefObject<FocusableElement | null>): FocusableContextValue {
3739
let context = useContext(FocusableContext) || {};

packages/@react-aria/tabs/src/useTab.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {DOMAttributes, FocusableElement, RefObject} from '@react-types/shared';
1515
import {filterDOMProps, mergeProps, useLinkProps} from '@react-aria/utils';
1616
import {generateId} from './utils';
1717
import {TabListState} from '@react-stately/tabs';
18+
import {useFocusable} from '@react-aria/focus';
1819
import {useSelectableItem} from '@react-aria/selection';
1920

2021
export interface TabAria {
@@ -60,9 +61,12 @@ export function useTab<T>(
6061
let domProps = filterDOMProps(item?.props, {labelable: true});
6162
delete domProps.id;
6263
let linkProps = useLinkProps(item?.props);
64+
let {focusableProps} = useFocusable({
65+
isDisabled
66+
}, ref);
6367

6468
return {
65-
tabProps: mergeProps(domProps, linkProps, itemProps, {
69+
tabProps: mergeProps(domProps, focusableProps, linkProps, itemProps, {
6670
id: tabId,
6771
'aria-selected': isSelected,
6872
'aria-disabled': isDisabled || undefined,

packages/@react-aria/tag/src/useTag.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import intlMessages from '../intl/*.json';
1919
import {KeyboardEvent} from 'react';
2020
import type {ListState} from '@react-stately/list';
2121
import {SelectableItemStates} from '@react-aria/selection';
22+
import {useFocusable, useInteractionModality} from '@react-aria/interactions';
2223
import {useGridListItem} from '@react-aria/gridlist';
23-
import {useInteractionModality} from '@react-aria/interactions';
2424
import {useLocalizedStringFormatter} from '@react-aria/i18n';
2525

2626

@@ -93,6 +93,10 @@ export function useTag<T>(props: AriaTagProps<T>, state: ListState<T>, ref: RefO
9393

9494
let domProps = filterDOMProps(item.props);
9595
let linkProps = useSyntheticLinkProps(item.props);
96+
let {focusableProps} = useFocusable({
97+
isDisabled
98+
}, ref);
99+
96100
return {
97101
removeButtonProps: {
98102
'aria-label': stringFormatter.format('removeButtonLabel'),
@@ -102,7 +106,7 @@ export function useTag<T>(props: AriaTagProps<T>, state: ListState<T>, ref: RefO
102106
onPress: () => onRemove ? onRemove(new Set([item.key])) : null,
103107
excludeFromTabOrder: true
104108
},
105-
rowProps: mergeProps(rowProps, domProps, linkProps, {
109+
rowProps: mergeProps(focusableProps, rowProps, domProps, linkProps, {
106110
tabIndex,
107111
onKeyDown: onRemove ? onKeyDown : undefined,
108112
'aria-describedby': descProps['aria-describedby']

packages/@react-aria/virtualizer/src/VirtualizerItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export function layoutInfoToStyle(layoutInfo: LayoutInfo, dir: Direction, parent
8888
...rectStyles
8989
};
9090

91-
if (layoutInfo.isSticky) {
91+
if (layoutInfo.isSticky && !parent?.allowOverflow) {
9292
if (style.top) {
9393
style.marginTop = style.top;
9494
}

packages/@react-spectrum/list/src/ListViewLayout.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
* governing permissions and limitations under the License.
1111
*/
1212
import {InvalidationContext, LayoutInfo, Rect} from '@react-stately/virtualizer';
13-
import {LayoutNode, ListLayout} from '@react-stately/layout';
13+
import {LayoutNode, ListLayout, ListLayoutOptions} from '@react-stately/layout';
1414
import {Node} from '@react-types/shared';
1515

16-
interface ListViewLayoutProps {
16+
interface ListViewLayoutProps extends ListLayoutOptions {
1717
isLoading?: boolean
1818
}
1919

packages/@react-spectrum/listbox/src/ListBoxLayout.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {InvalidationContext, LayoutInfo, Rect} from '@react-stately/virtualizer'
22
import {LayoutNode, ListLayout, ListLayoutOptions} from '@react-stately/layout';
33
import {Node} from '@react-types/shared';
44

5-
interface ListBoxLayoutProps {
5+
interface ListBoxLayoutProps extends ListLayoutOptions {
66
isLoading?: boolean
77
}
88

0 commit comments

Comments
 (0)