-
Notifications
You must be signed in to change notification settings - Fork 1.4k
docs: shouldCloseOnSelect, interactOutsideBehavior, and new viewport css vars #9855
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
39e9c85
4eadcdd
da16155
8f7c95b
19768ba
0e4927b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -339,6 +339,27 @@ import {ChevronLeft, ChevronRight} from 'lucide-react'; | |||||
| </RangeCalendar> | ||||||
| ``` | ||||||
|
|
||||||
| ## Interact outside behavior | ||||||
|
|
||||||
| Use the `interactOutsideBehavior` prop to control what happens when a range selection is in progress and the user interacts outside the calendar. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| ```tsx render docs={docs.exports.RangeCalendar} links={docs.links} props={['interactOutsideBehavior']} initialProps={{interactOutsideBehavior: 'select'}} | ||||||
| "use client"; | ||||||
| import {RangeCalendar} from 'vanilla-starter/RangeCalendar'; | ||||||
| import {parseDate} from '@internationalized/date'; | ||||||
|
|
||||||
| <RangeCalendar | ||||||
| aria-label="Trip dates" | ||||||
| defaultValue={{ | ||||||
| start: parseDate('2025-02-03'), | ||||||
| end: parseDate('2025-02-12') | ||||||
| }} | ||||||
| ///- begin highlight -/// | ||||||
| /* PROPS */ | ||||||
| ///- end highlight -/// | ||||||
| /> | ||||||
| ``` | ||||||
|
|
||||||
| ## API | ||||||
|
|
||||||
| <Anatomy | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,7 @@ export const description = 'Displays a collapsible list of options and allows a | |
| <PageDescription>{docs.exports.Select.description}</PageDescription> | ||
|
|
||
| <ExampleSwitcher> | ||
| ```tsx render docs={vanillaDocs.exports.Select} links={docs.links} props={['label', 'placeholder', 'selectionMode', 'isDisabled']} initialProps={{label: 'Favorite Animal'}} type="vanilla" files={["starters/docs/src/Select.tsx", "starters/docs/src/Select.css"]} | ||
| ```tsx render docs={vanillaDocs.exports.Select} links={docs.links} props={['label', 'placeholder', 'selectionMode', 'isDisabled', 'shouldCloseOnSelect']} initialProps={{label: 'Favorite Animal', shouldCloseOnSelect: true}} type="vanilla" files={["starters/docs/src/Select.tsx", "starters/docs/src/Select.css"]} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This results in weird behavior because then multi-select will also close on select which is not the default. I say just omit this. It's a rare use case. |
||
| "use client"; | ||
| import {Select, SelectItem} from 'vanilla-starter/Select'; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,7 +44,7 @@ function Example() { | |
| end: parseDate('2025-02-12') | ||
| }); | ||
| let formatter = useDateFormatter({ dateStyle: 'long' }); | ||
|
|
||
| return ( | ||
| <> | ||
| <RangeCalendar | ||
|
|
@@ -243,6 +243,27 @@ function Example() { | |
| } | ||
| ``` | ||
|
|
||
| ## Interact outside behavior | ||
|
|
||
| Use the `interactOutsideBehavior` prop to control what happens when a range selection is in progress and the user interacts outside the calendar. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
|
|
||
| ```tsx render docs={docs.exports.RangeCalendar} links={docs.links} props={['interactOutsideBehavior']} initialProps={{interactOutsideBehavior: 'select'}} type="s2" | ||
| "use client"; | ||
| import {RangeCalendar} from '@react-spectrum/s2'; | ||
| import {parseDate} from '@internationalized/date'; | ||
|
|
||
| <RangeCalendar | ||
| aria-label="Trip dates" | ||
| defaultValue={{ | ||
| start: parseDate('2025-02-03'), | ||
| end: parseDate('2025-02-12') | ||
| }} | ||
| ///- begin highlight -/// | ||
| /* PROPS */ | ||
| ///- end highlight -/// | ||
| /> | ||
| ``` | ||
|
|
||
| ## API | ||
|
|
||
| <PropTable component={docs.exports.RangeCalendar} links={docs.links} /> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be ok just having this in the prop table, not sure what other people think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree. Add it as a prop control to the top example as well.