Skip to content

Commit 848174d

Browse files
committed
RTL support for Keyboard accessibility
1 parent d5afcec commit 848174d

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Better type support for TypeScript
66
- MapDaysProps added to the index.d.ts [#288](https://github.com/shahabyazdi/react-multi-date-picker/issues/288)
77
- Calling onYearChange after year change in fullYear mode [#277](https://github.com/shahabyazdi/react-multi-date-picker/issues/277)
8+
- RTL support for Keyboard accessibility
89

910
# 4.5.0
1011

src/shared/handleFocus.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ export default function handleFocus(e, object, { type = "day", format }) {
1212

1313
const { currentTarget, key, code } = e;
1414
const skip = type === "day" ? 7 : 3;
15+
const calendar = findCalendar(currentTarget);
16+
const isRtl = calendar && calendar.classList.contains("rmdp-rtl");
1517

1618
const numbers = {
17-
ArrowRight: 1,
18-
ArrowLeft: -1,
19+
ArrowRight: isRtl ? -1 : 1,
20+
ArrowLeft: isRtl ? 1 : -1,
1921
ArrowUp: -skip,
2022
ArrowDown: skip,
2123
};
@@ -48,8 +50,6 @@ export default function handleFocus(e, object, { type = "day", format }) {
4850
}
4951

5052
function next() {
51-
const calendar = findCalendar(currentTarget);
52-
5353
if (type === "month") return findFocusable(calendar, [array[2]]);
5454

5555
const button = findNode(

0 commit comments

Comments
 (0)