File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import type {
16
16
import {
17
17
componentWithForwardedRef ,
18
18
dispatchDiscreteCustomEvent ,
19
+ getDirection ,
19
20
useDeterministicId ,
20
21
useEventCallback ,
21
22
useEventListener ,
@@ -244,6 +245,12 @@ const MenuBase = (props: Props, ref: React.Ref<HTMLDivElement>) => {
244
245
activeElement ,
245
246
) ;
246
247
248
+ const dir = getDirection ( event . currentTarget as HTMLElement ) ;
249
+
250
+ const sameDirectionKey = dir === "rtl" ? SystemKeys . LEFT : SystemKeys . RIGHT ;
251
+ const oppositeDirectionKey =
252
+ dir === "rtl" ? SystemKeys . RIGHT : SystemKeys . LEFT ;
253
+
247
254
if ( currentFocusedElement ) {
248
255
switch ( event . key ) {
249
256
case SystemKeys . ESCAPE : {
@@ -322,7 +329,7 @@ const MenuBase = (props: Props, ref: React.Ref<HTMLDivElement>) => {
322
329
break ;
323
330
}
324
331
325
- case SystemKeys . LEFT : {
332
+ case oppositeDirectionKey : {
326
333
event . preventDefault ( ) ;
327
334
328
335
const { item } = currentFocusedElement ;
@@ -346,7 +353,7 @@ const MenuBase = (props: Props, ref: React.Ref<HTMLDivElement>) => {
346
353
break ;
347
354
}
348
355
349
- case SystemKeys . RIGHT : {
356
+ case sameDirectionKey : {
350
357
event . preventDefault ( ) ;
351
358
352
359
const { item } = currentFocusedElement ;
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @styleless-ui/react" ,
3
- "version" : " 1.0.0-rc.4 " ,
3
+ "version" : " 1.0.0-rc.5 " ,
4
4
"description" : " Completely unstyled, headless and accessible React UI components." ,
5
5
"author" : " mimshins <mostafa.sh.coderino@gmail.com>" ,
6
6
"license" : " MIT" ,
You can’t perform that action at this time.
0 commit comments