Skip to content

Commit

Permalink
🔨 Remove the "react-datepicker__week-number--keyboard-selected" class…
Browse files Browse the repository at this point in the history
… for the <WeekNumber /> component

- Removed as highlighting the first day of the week alone highlights the week number - Because we set the date prop of the <WeekNumber /> to first date of the week.  As a result this highlight will work only for the first day of week
  • Loading branch information
Balaji-Sridharan_NYULH authored and Balaji-Sridharan_NYULH committed Nov 17, 2024
1 parent 30babb9 commit ce8508f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 70 deletions.
68 changes: 0 additions & 68 deletions src/test/week_number_test.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,6 @@ describe("WeekNumber", () => {
) as HTMLDivElement;
expect(weekNumber).not.toBeNull();

expect(
weekNumber?.classList.contains(
"react-datepicker__week-number--keyboard-selected",
),
).toBe(false);
expect(weekNumber?.tabIndex).toBe(0);
});

Expand All @@ -212,11 +207,6 @@ describe("WeekNumber", () => {
".react-datepicker__week-number",
) as HTMLDivElement;
expect(weekNumber).not.toBeNull();
expect(
weekNumber?.classList.contains(
"react-datepicker__week-number--keyboard-selected",
),
).toBe(true);
expect(weekNumber.tabIndex).toBe(0);
});

Expand Down Expand Up @@ -267,11 +257,6 @@ describe("WeekNumber", () => {
const weekNumber = container.querySelector(
".react-datepicker__week-number",
) as HTMLDivElement;
expect(
weekNumber?.classList.contains(
"react-datepicker__week-number--keyboard-selected",
),
).toBe(false);
expect(weekNumber.tabIndex).toBe(-1);
});
});
Expand Down Expand Up @@ -383,59 +368,6 @@ describe("WeekNumber", () => {
),
).toBe(false);
});

it("should have the class 'react-datepicker__week-number--selected' if selected is not current week and preselected is current week", () => {
const currentWeekNumber = newDate("2023-10-22T13:09:53+02:00");
const selected = addWeeks(currentWeekNumber, 1);
const { container } = render(
<WeekNumber
weekNumber={1}
date={currentWeekNumber}
selected={selected}
preSelection={currentWeekNumber}
/>,
);
const weekNumber = container.querySelector(
".react-datepicker__week-number",
);
expect(
weekNumber?.classList.contains(
"react-datepicker__week-number--selected",
),
).toBe(false);
expect(
weekNumber?.classList.contains(
"react-datepicker__week-number--keyboard-selected",
),
).toBe(true);
});

it("should have the class 'react-datepicker__week-number--selected' if selected is not current week and preselected is not current week", () => {
const currentWeekNumber = newDate("2023-10-22T13:09:53+02:00");
const selected = addWeeks(currentWeekNumber, 1);
const preSelection = addWeeks(currentWeekNumber, 2);
const { container } = render(
<WeekNumber
weekNumber={1}
date={currentWeekNumber}
selected={selected}
preSelection={preSelection}
/>,
);
const weekNumber = container.querySelector(
".react-datepicker__week-number",
);
expect(
weekNumber?.classList.contains(
"react-datepicker__week-number--selected",
),
).toBe(false);
expect(
weekNumber?.classList.contains(
"react-datepicker__week-number--keyboard-selected",
),
).toBe(false);
});
});
});

Expand Down
2 changes: 0 additions & 2 deletions src/week_number.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ export default class WeekNumber extends Component<WeekNumberProps> {
"react-datepicker__week-number--clickable": !!onClick,
"react-datepicker__week-number--selected":
!!onClick && isSameDay(this.props.date, this.props.selected),
"react-datepicker__week-number--keyboard-selected":
this.isKeyboardSelected(),
};
return (
<div
Expand Down

0 comments on commit ce8508f

Please sign in to comment.