-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(date-picker): month and year picker scroller #3789
Open
buchananwill
wants to merge
20
commits into
heroui-inc:canary
Choose a base branch
from
buchananwill:fix/date-picker-month-and-year-scroller
base: canary
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
4895941
accordion tree
buchananwill 7968f1a
Rename accordionTree.tsx to accordion-tree.tsx
buchananwill 3b77e2e
Update accordion-tree.tsx
buchananwill 5f35a84
fix(use-calendar-picker): fixed the UI month/year sync (#3785)
buchananwill 66108cd
fix(use-calendar-picker): fixed the UI month/year sync (#3785)
buchananwill d6b00bc
fix(use-calendar-picker): added test for the fixed behaviour (#3785)
buchananwill e30ae3c
fix(use-calendar-picker): changeset (#3785)
buchananwill d4cc930
Delete .changeset/serious-snails-count.md
buchananwill cb2d7fe
Update sixty-weeks-help.md
buchananwill 928237b
fix(use-calendar-picker): swapped the aria label for data-slot="heade…
buchananwill 5bc25d5
fix(use-calendar-picker): added scrollTo(nextValue, list) into the ke…
buchananwill e6a2f99
fix(use-calendar-picker): prevent default behaviour for scroll keys
buchananwill 0a2c4c9
fix(use-calendar-picker): add a key up event to further fix #3789
buchananwill 5ec489b
fix(use-calendar-picker): changed the home/end values to 1 and 12
buchananwill 151141c
fix(use-calendar-picker): sourced the mix/max values from the state
buchananwill cc5ca02
fix(use-calendar-picker): useCallback for the getBoundaryValue
buchananwill 243befa
fix(use-calendar-picker): blocking repeat key strokes for home and end
buchananwill c3f924b
fix(use-calendar-picker): inlined arrow function
buchananwill b96542a
fix(use-calendar-picker): simplified control structure
buchananwill 214385f
fix(use-calendar-picker): change the execution order to avoid stale l…
buchananwill File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@nextui-org/accordion": minor | ||
"@nextui-org/calendar": patch | ||
--- | ||
|
||
Fixing the UI and data syncing of the month/year picker. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@nextui-org/accordion": patch | ||
"@nextui-org/calendar": patch | ||
"@nextui-org/date-picker": patch | ||
--- | ||
|
||
Added an aria and test label for the picker toggle. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ import {pointerMap, triggerPress} from "@nextui-org/test-utils"; | |
import userEvent from "@testing-library/user-event"; | ||
import {CalendarDate, CalendarDateTime} from "@internationalized/date"; | ||
import {NextUIProvider} from "@nextui-org/system"; | ||
import {monthAndYearPickerToggle} from "@nextui-org/calendar/src/calendar-header"; | ||
|
||
import {DatePicker as DatePickerBase, DatePickerProps} from "../src"; | ||
|
||
|
@@ -524,6 +525,7 @@ describe("DatePicker", () => { | |
|
||
describe("Month and Year Picker", () => { | ||
const onHeaderExpandedChangeSpy = jest.fn(); | ||
const valueChangeSpy = jest.fn(); | ||
|
||
afterEach(() => { | ||
onHeaderExpandedChangeSpy.mockClear(); | ||
|
@@ -600,6 +602,48 @@ describe("DatePicker", () => { | |
expect(onHeaderExpandedChangeSpy).not.toHaveBeenCalled(); | ||
}); | ||
|
||
it("should focus the month and year when pressed in the picker", () => { | ||
ryo-manba marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const {getByRole, getByLabelText} = render( | ||
<DatePicker | ||
showMonthAndYearPickers | ||
calendarProps={{ | ||
isHeaderExpanded: true, | ||
onChange: valueChangeSpy, | ||
}} | ||
defaultValue={new CalendarDate(2024, 4, 26)} | ||
label="Date" | ||
/>, | ||
); | ||
const dialogButton = getByRole("button"); | ||
|
||
triggerPress(dialogButton); | ||
|
||
const dialog = getByRole("dialog"); | ||
const month = getByRole("button", {name: "April"}); | ||
const year = getByRole("button", {name: "2024"}); | ||
|
||
expect(dialog).toBeVisible(); | ||
expect(month).toHaveAttribute("data-value", "4"); | ||
expect(year).toHaveAttribute("data-value", "2024"); | ||
|
||
const button = getByLabelText(monthAndYearPickerToggle); | ||
|
||
triggerPress(button); | ||
|
||
const monthBefore = getByRole("button", {name: "March"}); | ||
const yearBefore = getByRole("button", {name: "2023"}); | ||
|
||
expect(monthBefore).toHaveAttribute("data-value", "3"); | ||
expect(yearBefore).toHaveAttribute("data-value", "2023"); | ||
expect(monthBefore).toHaveAttribute("tabindex", "-1"); | ||
expect(yearBefore).toHaveAttribute("tabindex", "-1"); | ||
triggerPress(monthBefore); | ||
triggerPress(yearBefore); | ||
expect(valueChangeSpy).not.toHaveBeenCalled(); | ||
expect(monthBefore).toHaveAttribute("tabindex", "0"); | ||
expect(yearBefore).toHaveAttribute("tabindex", "0"); | ||
Comment on lines
+641
to
+643
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please also check the following two points:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add tests. |
||
}); | ||
wingkwong marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
it("CalendarBottomContent should render correctly", () => { | ||
const {getByRole, getByTestId} = render( | ||
<DatePicker | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't hardcode
aria-label
internally. We can take it from users' side tho.