You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/dev/docs/pages/blog/building-a-combobox.mdx
+4-4
Original file line number
Diff line number
Diff line change
@@ -63,7 +63,7 @@ space for the tray.
63
63
64
64
Luckily for us, iOS 13 added support for the [VisualViewport](https://developer.mozilla.org/en-US/docs/Web/API/VisualViewport) API. By querying `window.visualViewport.height` we could get a reliable measurement of how much vertical space was available on screen. Furthermore, we could track
65
65
when the onscreen keyboard was opened or dismissed by listening to the VisualViewport's `resize` event. Leveraging these two allowed us to create a tray that properly adjusts to the presence of iOS onscreen keyboard. Check out the video below
66
-
to see how the ComboBox tray worked before and after we switched to the VisualViewport API. If you'd like to track the visual viewport size in your own app, you can use the [useViewportSize](https://github.com/adobe/react-spectrum/blob/main/packages/@react-aria-nutrient/utils/src/useViewportSize.ts) hook available in the `@react-aria-nutrient/utils` package.
66
+
to see how the ComboBox tray worked before and after we switched to the VisualViewport API. If you'd like to track the visual viewport size in your own app, you can use the [useViewportSize](https://github.com/adobe/react-spectrum/blob/main/packages/@react-aria/utils/src/useViewportSize.ts) hook available in the `@react-aria-nutrient/utils` package.
@@ -72,7 +72,7 @@ to see how the ComboBox tray worked before and after we switched to the VisualVi
72
72
Another issue we encountered had to do with iOS Safari page scrolling behavior. When the onscreen keyboard is visible, iOS Safari makes the page scrollable so that users can still access content that is hidden behind the keyboard. However,
73
73
now that our ComboBox tray sizes itself to fit in the visual viewport, users could now scroll the entire tray itself off screen. To stop this from happening, we prevent default on `touchmove` events that happen on the document body
74
74
or root element of the document. This preserves the user's ability to scroll through the options in the tray but blocks any attempt to scroll the page itself until the tray is closed. The video below
75
-
illustrates the difference in scrolling behavior before and after our fix. If you are building your own overlays and would like to prevent this kind of document scrolling behavior, check out the [usePreventScroll](https://github.com/adobe/react-spectrum/blob/main/packages/@react-aria-nutrient/overlays/src/usePreventScroll.ts) hook in the `react-aria/overlays` package.
75
+
illustrates the difference in scrolling behavior before and after our fix. If you are building your own overlays and would like to prevent this kind of document scrolling behavior, check out the [usePreventScroll](https://github.com/adobe/react-spectrum/blob/main/packages/@react-aria/overlays/src/usePreventScroll.ts) hook in the `react-aria/overlays` package.
@@ -94,7 +94,7 @@ set. Therefore, we had to figure out a way to make the input and listbox the onl
94
94
The solution that we came up with was to crawl the DOM and apply `aria-hidden` to every element that wasn't the input or listbox. To crawl the DOM we used a [TreeWalker](https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker),
95
95
setting up a node filter to determine if a node should be left visible, hidden, or skipped in the case where its parent was already hidden. In addition, we watch for any changes in the DOM while the listbox is open
96
96
via a [MutationObserver](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver), hiding those new elements if need be. When the popover closes, every node that we modified is reverted back to its previous state.
97
-
Check out our [ariaHideOutside](https://github.com/adobe/react-spectrum/blob/main/packages/@react-aria-nutrient/overlays/src/ariaHideOutside.ts) function in `@react-aria-nutrient/overlays` if you'd like to learn more.
97
+
Check out our [ariaHideOutside](https://github.com/adobe/react-spectrum/blob/main/packages/@react-aria/overlays/src/ariaHideOutside.ts) function in `@react-aria-nutrient/overlays` if you'd like to learn more.
98
98
99
99
### Mobile implementation divergence
100
100
@@ -133,7 +133,7 @@ Special care was taken such that the messages themselves only contained relevant
133
133
When the user then moves to a different option in the same section, only the newly focused item name is announced. Similarly, the total option count is only announced when number of options available in the listbox changes. Since many of these messages were added to fill in gaps in VoiceOver's announcement,
134
134
we only trigger the `LiveAnnouncer` on Apple devices to avoid announcement overlap on other screen readers.
135
135
136
-
If you are interested in using this `LiveAnnouncer` yourself, check out [LiveAnnouncer](https://github.com/adobe/react-spectrum/blob/main/packages/@react-aria-nutrient/live-announcer/src/LiveAnnouncer.tsx) in `@react-aria-nutrient/live-announcer`. Otherwise, the [useComboBox](../react-aria/useComboBox.html) hook provides you with all of the custom messaging out of the box. See the video below for a sneak peek!
136
+
If you are interested in using this `LiveAnnouncer` yourself, check out [LiveAnnouncer](https://github.com/adobe/react-spectrum/blob/main/packages/@react-aria/live-announcer/src/LiveAnnouncer.tsx) in `@react-aria-nutrient/live-announcer`. Otherwise, the [useComboBox](../react-aria/useComboBox.html) hook provides you with all of the custom messaging out of the box. See the video below for a sneak peek!
137
137
138
138
<Videosrc={comboboxAccessibilityUrl}alt="Demo of VoiceOver announcement in ComboBox"style={{maxWidth: 'min(100%, 700px)', display: 'block', margin: '20px auto'}}controls />
0 commit comments