Skip to content

Commit

Permalink
Merge pull request #4356 from linuxlewis/main
Browse files Browse the repository at this point in the history
Update showQuarterYearPicker to respect disableKeyboardNavigation
  • Loading branch information
martijnrusschen authored Nov 7, 2023
2 parents 57885fa + 86cfd7d commit 411a360
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/month.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ export default class Month extends React.Component {
minDate,
maxDate,
preSelection,
disabledKeyboardNavigation
} = this.props;
return classnames(
"react-datepicker__quarter-text",
Expand All @@ -606,7 +607,7 @@ export default class Month extends React.Component {
selected,
),
"react-datepicker__quarter-text--keyboard-selected":
utils.getQuarter(preSelection) === q,
!disabledKeyboardNavigation && utils.getQuarter(preSelection) === q,
"react-datepicker__quarter-text--in-selecting-range":
this.isInSelectingRangeQuarter(q),
"react-datepicker__quarter-text--in-range": utils.isQuarterInRange(
Expand Down
23 changes: 23 additions & 0 deletions test/month_test.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,29 @@ describe("Month", () => {
utils.newDate("2015-01-01").toString(),
);
});

describe("if keyboard navigation is disabled", () => {
it("should not have the selected class", () => {
let preSelected = utils.newDate("2015-08-01");
const setPreSelection = (param) => {
preSelected = param;
};
const quartersComponent = renderQuarters({
selected: utils.newDate("2015-08-01"),
day: utils.newDate("2015-08-01"),
setPreSelection: setPreSelection,
preSelection: preSelected,
disabledKeyboardNavigation: true,
showQuarterYearPicker: true
});

expect(
quartersComponent
.find(".react-datepicker__quarter-text--selected")
.hasClass("react-datepicker__quarter-text--keyboard-selected"),
).toBe(false);
});
});
});

describe("Keyboard navigation", () => {
Expand Down

0 comments on commit 411a360

Please sign in to comment.