Skip to content

Commit 2ba829b

Browse files
authored
docs: Update docs for new --page-height var and ComboBox actions (#8955)
* chore: Update docs for new --page-height var and small audit fixes * add row action example for RAC combobox docs * clarify wording * clarify wording * ugh yarn lock * fix lint rule * fix docs type check * update copy * copy update and removing unstable from collection exports * prevent breaking change, update copy for one last example
1 parent 8a49fc9 commit 2ba829b

File tree

9 files changed

+49
-10
lines changed

9 files changed

+49
-10
lines changed

packages/dev/mcp/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"zod": "^3.23.8"
1717
},
1818
"devDependencies": {
19-
"@adobe/spectrum-css-temp": "3.0.0-alpha.1",
2019
"typescript": "^5.8.2"
2120
},
2221
"engines": {

packages/dev/s2-docs/pages/react-aria/ComboBox.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ function ControlledComboBox() {
234234

235235
## Item actions
236236

237-
Use the `onAction` prop on a `<ListBoxItem>` to perform a custom action when the item is selected. This example adds a "Create" action for the current input value.
237+
Use the `onAction` prop on a `<ListBoxItem>` to perform a custom action when the item is pressed. This example adds a "Create" action for the current input value.
238238

239239
```tsx render
240240
"use client";

packages/dev/s2-docs/pages/s2/ComboBox.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ function Example() {
189189

190190
### Actions
191191

192-
Use the `onAction` prop on a `<ComboBoxItem>` to perform a custom action when the item is selected. This example adds a "Create" action for the current input value.
192+
Use the `onAction` prop on a `<ComboBoxItem>` to perform a custom action when the item is pressed. This example adds a "Create" action for the current input value.
193193

194194
```tsx render
195195
"use client";

packages/react-aria-components/docs/Autocomplete.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import {StarterKits} from '@react-spectrum/docs/src/StarterKits';
3030
category: Pickers
3131
keywords: [autocomplete, search, menu, command palette, aria]
3232
type: component
33-
preRelease: beta
33+
preRelease: rc
3434
---
3535

3636
# Autocomplete

packages/react-aria-components/docs/ComboBox.mdx

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,9 +589,40 @@ function Example() {
589589
}
590590
```
591591

592+
## Item actions
593+
594+
Use the `onAction` prop on a `<ListBoxItem>` to perform a custom action when the item is pressed. This example adds a "Create" action for the current input value.
595+
596+
```tsx example
597+
function Example() {
598+
let [inputValue, setInputValue] = React.useState('');
599+
600+
return (
601+
<MyComboBox
602+
label="Favorite Animal"
603+
inputValue={inputValue}
604+
onInputChange={setInputValue}>
605+
{/*- begin highlight -*/}
606+
{inputValue.length > 0 && (
607+
<ListBoxItem onAction={() => alert('Creating ' + inputValue)}>
608+
{`Create "${inputValue}"`}
609+
</ListBoxItem>
610+
)}
611+
{/*- end highlight -*/}
612+
<ListBoxItem>Aardvark</ListBoxItem>
613+
<ListBoxItem>Cat</ListBoxItem>
614+
<ListBoxItem>Dog</ListBoxItem>
615+
<ListBoxItem>Kangaroo</ListBoxItem>
616+
<ListBoxItem>Panda</ListBoxItem>
617+
<ListBoxItem>Snake</ListBoxItem>
618+
</MyComboBox>
619+
);
620+
}
621+
```
622+
592623
## Links
593624

594-
By default, interacting with an item in a ComboBox selects it and updates the input value. Alternatively, items may be links to another page or website. This can be achieved by passing the `href` prop to the `<ListBoxItem>` component. Interacting with link items navigates to the provided URL and does not update the selection or input value.
625+
Items may be links to another page or website. This can be achieved by passing the `href` prop to the `<ListBoxItem>` component. Interacting with link items navigates to the provided URL and does not update the selection or input value.
595626

596627
```tsx example
597628
<MyComboBox label="Tech company websites">

packages/react-aria-components/docs/Modal.mdx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,12 +422,21 @@ A `Modal` can be targeted with the `.react-aria-Modal` CSS selector, or by overr
422422

423423
By default, `Modal` includes a builtin `ModalOverlay`, which renders a backdrop over the page when a modal is open. This can be targeted using the `.react-aria-ModalOverlay` CSS selector. To customize the `ModalOverlay` with a different class name or other attributes, render a `ModalOverlay` and place a `Modal` inside.
424424

425-
The `--visual-viewport-height` CSS custom property will be set on the `ModalOverlay`, which you can use to set the height to account for the virtual keyboard on mobile.
425+
The `--page-height` and `--visual-viewport-height` CSS custom property will be set on the `ModalOverlay`, the latter of which you can use to set the height of the Modal to account for the virtual keyboard on mobile.
426426

427427
```css render=false
428428
.react-aria-ModalOverlay {
429+
position: absolute;
430+
height: var(--page-height);
431+
}
432+
433+
.react-aria-Modal {
434+
/* Center modal without adding a extra wrapping div. */
429435
position: fixed;
430-
height: var(--visual-viewport-height);
436+
max-height: var(--visual-viewport-height);
437+
top: calc(var(--visual-viewport-height) / 2);
438+
left: 50%;
439+
translate: -50% -50%;
431440
}
432441
```
433442

packages/react-aria-components/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ export {Header, HeaderContext} from './Header';
4545
export {Heading} from './Heading';
4646
export {Input, InputContext} from './Input';
4747
export {Section, CollectionRendererContext, DefaultCollectionRenderer} from './Collection';
48-
export {Collection, createLeafComponent as UNSTABLE_createLeafComponent, createBranchComponent as UNSTABLE_createBranchComponent, CollectionBuilder as UNSTABLE_CollectionBuilder} from '@react-aria/collections';
48+
export {createLeafComponent as UNSTABLE_createLeafComponent, createBranchComponent as UNSTABLE_createBranchComponent, CollectionBuilder as UNSTABLE_CollectionBuilder} from '@react-aria/collections';
49+
export {Collection, createLeafComponent, createBranchComponent, CollectionBuilder} from '@react-aria/collections';
4950
export {Keyboard, KeyboardContext} from './Keyboard';
5051
export {Label, LabelContext} from './Label';
5152
export {Link, LinkContext} from './Link';

yarn.config.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function enforceConsistentDependenciesAcrossTheProject({Yarn}) {
5555

5656
workspace.set('dependencies.@swc/helpers', '^0.5.0');
5757
workspace.set('dependencies.@adobe/spectrum-css-temp');
58-
if (workspace.ident.startsWith('@react-spectrum') && !workspace.ident.endsWith('/utils')) {
58+
if (workspace.ident.startsWith('@react-spectrum') && !workspace.ident.endsWith('/utils') && !workspace.ident.endsWith('/mcp')) {
5959
workspace.set('devDependencies.@adobe/spectrum-css-temp', '3.0.0-alpha.1');
6060
}
6161
// these should not be in dependencies, but should be in dev or peer

yarn.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7211,7 +7211,6 @@ __metadata:
72117211
version: 0.0.0-use.local
72127212
resolution: "@react-spectrum/mcp@workspace:packages/dev/mcp"
72137213
dependencies:
7214-
"@adobe/spectrum-css-temp": "npm:3.0.0-alpha.1"
72157214
"@modelcontextprotocol/sdk": "npm:^1.17.3"
72167215
"@swc/helpers": "npm:^0.5.0"
72177216
fast-glob: "npm:^3.3.3"

0 commit comments

Comments
 (0)