Skip to content

Commit 894e49d

Browse files
authored
Merge branch 'main' into avatar-in-combobox-and-picker
2 parents 753b3db + 836dc5d commit 894e49d

File tree

18 files changed

+76
-11
lines changed

18 files changed

+76
-11
lines changed

.storybook-s2/docs/Migrating.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ export function Migrating() {
300300
<li className={style({font: 'body', marginY: 8})}>Remove <Code>validationState="valid"</Code> (it is no longer supported in Spectrum 2)</li>
301301
<li className={style({font: 'body', marginY: 8})}>Update <Code>Item</Code> to be a <Code>PickerItem</Code></li>
302302
<li className={style({font: 'body', marginY: 8})}>Change <Code>isLoading</Code> to <Code>loadingState</Code> and provide the appropriate loading state.</li>
303+
<li className={style({font: 'body', marginY: 8})}><Code>defaultSelectedKey</Code> and <Code>selectedKey</Code> have been deprecated in favor of <Code>defaultValue</Code> and <Code>value</Code> respectively. See the <Link href="?path=/docs/picker--docs">props table</Link> for the new accepted types.</li>
303304
</ul>
304305

305306
<H3>ProgressBar</H3>

packages/@adobe/spectrum-css-temp/components/tray/index.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
/* Add padding at the bottom to account for the rest of the viewport height behind the keyboard.
5656
* This is necessary so that there isn't a visible gap that appears while the keyboard is animating
5757
* in and out. Fall back to the safe area inset to account for things like iOS home indicator.
58-
We also add an additional 100vh of padding (offset by the bottom position below) so the tray
58+
We also add an additional 100vh of padding (offset by the bottom position below) so the tray
5959
extends behind Safari's address bar and keyboard in iOS 26. */
6060
padding-bottom: calc(max(calc(100dvh - var(--spectrum-visual-viewport-height)), env(safe-area-inset-bottom)) + 100vh);
6161
position: absolute;
@@ -75,6 +75,8 @@
7575
/* Exit animations */
7676
transition: opacity var(--spectrum-dialog-exit-animation-duration) cubic-bezier(0.5, 0, 1, 1) var(--spectrum-dialog-exit-animation-delay),
7777
transform var(--spectrum-dialog-exit-animation-duration) cubic-bezier(0.5, 0, 1, 1) var(--spectrum-dialog-exit-animation-delay);
78+
79+
box-sizing: content-box;
7880
}
7981

8082
.is-open {

packages/@react-aria/combobox/src/useComboBox.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {AriaComboBoxProps} from '@react-types/combobox';
1616
import {ariaHideOutside} from '@react-aria/overlays';
1717
import {AriaListBoxOptions, getItemId, listData} from '@react-aria/listbox';
1818
import {BaseEvent, DOMAttributes, KeyboardDelegate, LayoutDelegate, PressEvent, RefObject, RouterOptions, ValidationResult} from '@react-types/shared';
19-
import {chain, getActiveElement, getOwnerDocument, isAppleDevice, mergeProps, useLabels, useRouter, useUpdateEffect} from '@react-aria/utils';
19+
import {chain, getActiveElement, getOwnerDocument, isAppleDevice, mergeProps, useEvent, useLabels, useRouter, useUpdateEffect} from '@react-aria/utils';
2020
import {ComboBoxState} from '@react-stately/combobox';
2121
import {dispatchVirtualFocus} from '@react-aria/focus';
2222
import {FocusEvent, InputHTMLAttributes, KeyboardEvent, TouchEvent, useEffect, useMemo, useRef} from 'react';
@@ -354,6 +354,10 @@ export function useComboBox<T>(props: AriaComboBoxOptions<T>, state: ComboBoxSta
354354
}
355355
}, [focusedItem]);
356356

357+
useEvent(listBoxRef, 'react-aria-item-action', state.isOpen ? () => {
358+
state.close();
359+
} : undefined);
360+
357361
return {
358362
labelProps,
359363
buttonProps: {
@@ -383,7 +387,8 @@ export function useComboBox<T>(props: AriaComboBoxOptions<T>, state: ComboBoxSta
383387
shouldUseVirtualFocus: true,
384388
shouldSelectOnPressUp: true,
385389
shouldFocusOnHover: true,
386-
linkBehavior: 'selection' as const
390+
linkBehavior: 'selection' as const,
391+
['UNSTABLE_itemBehavior']: 'action'
387392
}),
388393
descriptionProps,
389394
errorMessageProps,

packages/@react-aria/listbox/src/useListBox.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ export function useListBox<T>(props: AriaListBoxOptions<T>, state: ListState<T>,
100100
shouldFocusOnHover: props.shouldFocusOnHover,
101101
isVirtualized: props.isVirtualized,
102102
onAction: props.onAction,
103-
linkBehavior
103+
linkBehavior,
104+
// @ts-ignore
105+
UNSTABLE_itemBehavior: props['UNSTABLE_itemBehavior']
104106
});
105107

106108
let {labelProps, fieldProps} = useLabel({

packages/@react-aria/listbox/src/useOption.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ export function useOption<T>(props: AriaOptionProps, state: ListState<T>, ref: R
137137
isDisabled,
138138
onAction: onAction || item?.props?.onAction ? chain(item?.props?.onAction, onAction) : undefined,
139139
linkBehavior: data?.linkBehavior,
140+
// @ts-ignore
141+
UNSTABLE_itemBehavior: data?.['UNSTABLE_itemBehavior'],
140142
id
141143
});
142144

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,9 @@ export function useSelectableItem(options: SelectableItemOptions): SelectableIte
205205
// With highlight selection, onAction is secondary, and occurs on double click. Single click selects the row.
206206
// With touch, onAction occurs on single tap, and long press enters selection mode.
207207
let isLinkOverride = manager.isLink(key) && linkBehavior === 'override';
208+
let isActionOverride = onAction && options['UNSTABLE_itemBehavior'] === 'action';
208209
let hasLinkAction = manager.isLink(key) && linkBehavior !== 'selection' && linkBehavior !== 'none';
209-
let allowsSelection = !isDisabled && manager.canSelectItem(key) && !isLinkOverride;
210+
let allowsSelection = !isDisabled && manager.canSelectItem(key) && !isLinkOverride && !isActionOverride;
210211
let allowsActions = (onAction || hasLinkAction) && !isDisabled;
211212
let hasPrimaryAction = allowsActions && (
212213
manager.selectionBehavior === 'replace'
@@ -225,6 +226,7 @@ export function useSelectableItem(options: SelectableItemOptions): SelectableIte
225226
let performAction = (e) => {
226227
if (onAction) {
227228
onAction();
229+
ref.current?.dispatchEvent(new CustomEvent('react-aria-item-action', {bubbles: true}));
228230
}
229231

230232
if (hasLinkAction && ref.current) {

packages/@react-spectrum/s2/src/Disclosure.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,10 @@ const panelStyles = style({
299299
font: 'body',
300300
height: '--disclosure-panel-height',
301301
overflow: 'clip',
302-
transition: '[height]'
302+
transition: {
303+
default: '[height]',
304+
'@media (prefers-reduced-motion: reduce)': 'none'
305+
}
303306
});
304307

305308
const panelInner = style({

packages/@react-spectrum/s2/stories/ComboBox.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ export function WithCreateOption() {
345345
return (
346346
<ComboBox
347347
label="Favorite Animal"
348+
placeholder="Select an animal"
348349
inputValue={inputValue}
349350
onInputChange={setInputValue}>
350351
{inputValue.length > 0 && (

packages/@react-spectrum/s2/stories/Picker.stories.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ const meta: Meta<typeof Picker<any>> = {
4949
description: {control: {type: 'text'}},
5050
errorMessage: {control: {type: 'text'}},
5151
children: {table: {disable: true}},
52-
contextualHelp: {table: {disable: true}}
52+
contextualHelp: {table: {disable: true}},
53+
defaultSelectedKey: {table: {disable: true}},
54+
selectedKey: {table: {disable: true}}
5355
},
5456
args: {...getActionArgs(events)},
5557
title: 'Picker'

packages/dev/s2-docs/pages/react-aria/SegmentedControl.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
border-radius: 8px;
1818
background: var(--gray-50);
1919
outline: 2px solid var(--gray-600);
20+
21+
@media (prefers-reduced-motion: reduce) {
22+
transition: none;
23+
}
2024
}
2125

2226
.segmented-control-item {

0 commit comments

Comments
 (0)