Skip to content

Commit 150b26e

Browse files
committed
clarify keyboard navigation
1 parent b6cf32e commit 150b26e

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

packages/dev/docs/pages/blog/rtl-date-time.mdx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ import placeholderVideoURL from 'url:../assets/datefield-placeholder.mp4';
1717
import keyboardVideoURL from 'url:../assets/rtl-keyboard.mp4';
1818

1919

20-
```jsx import
2120

21+
```jsx import
22+
import {I18nProvider} from 'react-aria';
23+
import {DateField} from '@adobe/react-spectrum';
24+
import {parseZonedDateTime} from '@internationalized/date';
2225
```
2326

2427
---
@@ -115,13 +118,28 @@ Through much trial and error, we discovered that appplying the [left-to-right em
115118

116119
## Keyboard Navigation
117120

118-
After fixing the formatting, we also needed to update the keyboard navigation. Previously, when pressing the left arrow key, you would go to the next node in the DOM and vice versa for the right arrow key. After these changes though, visually adjacent elements were not necessarily adjacent in the DOM so this would not work anymore.
121+
After fixing the formatting, we also needed to update the keyboard navigation. Previously, when pressing the left arrow key, you would go to the next node in the DOM and vice versa for the right arrow key. However, after these changes, visually adjacent elements were not necessarily adjacent in the DOM so this would not work anymore. For example, in Hebrew (`he-IL`), the day and minute segment are supposed to be visually adjacent (e.g. `HH:MM DD.MM.YYYY`), but in the DOM, there are several other segments between them.
122+
123+
```tsx example render=false
124+
// An example of the DOM structure of a date field in he-IL
125+
<div>
126+
<span aria-label="day">3</span>
127+
<span>.</span>
128+
<span aria-label="month">11</span>
129+
<span>.</span>
130+
<span aria-label="year">2020</span>
131+
<span>,</span>
132+
<span aria-label="hour">8</span>
133+
<span>:</span>
134+
<span aria-label="minute">45</span>
135+
</div>
136+
```
119137

120138
Below is an example of a date field in Hebrew with the correct date format but incorrect keyboard navigation. Pressing the left arrow key should navigate you to the segment to the immediate left, while the right arrow key should navigate you to the segment to the immediate right.
121139

122140
<Video src={keyboardVideoURL} loop autoPlay muted />
123141

124-
As a result, we updated the keyboard navigation in right-to-left langauges to rely on the positioning of the different segments to determine which node to receive focus for an intuitive keyboard experience.
142+
As a result, we updated the keyboard navigation in right-to-left langauges to calculate the distance between the currently focused segment and other segments to identify the closest node based on whether the left or right arrow key was pressed, rather than reying on the DOM order.
125143

126144
## Conclusion
127145

0 commit comments

Comments
 (0)