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
@@ -115,13 +118,28 @@ Through much trial and error, we discovered that appplying the [left-to-right em
115
118
116
119
## Keyboard Navigation
117
120
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
+
<spanaria-label="day">3</span>
127
+
<span>.</span>
128
+
<spanaria-label="month">11</span>
129
+
<span>.</span>
130
+
<spanaria-label="year">2020</span>
131
+
<span>,</span>
132
+
<spanaria-label="hour">8</span>
133
+
<span>:</span>
134
+
<spanaria-label="minute">45</span>
135
+
</div>
136
+
```
119
137
120
138
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.
121
139
122
140
<Videosrc={keyboardVideoURL}loopautoPlaymuted />
123
141
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.
0 commit comments