Skip to content
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

NEXT-38027 - fix datepicker not emiting value when manually entered #270

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/modern-numbers-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@shopware-ag/meteor-component-library": patch
---

Updated flatpickr dependency to the latest version to fix mt-datepicker issue when date typed manually
2 changes: 1 addition & 1 deletion packages/component-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@vueuse/core": "^10.7.2",
"date-fns": "^2.30.0",
"date-fns-tz": "^2.0.0",
"flatpickr": "4.6.3",
"flatpickr": "4.6.13",
"focus-trap": "^7.5.4",
"inter-ui": "^3.19.3",
"lodash-es": "^4.17.21",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export const VisualTestTimeInputValue: MtDatepickerStory = {
// Enter 22 as minute
await userEvent.clear(calendar.getByLabelText("Minute"));
await userEvent.type(calendar.getByLabelText("Minute"), "22");
await userEvent.type(canvas.getByRole("textbox"), "{enter}");

// Click label to close datepicker
await userEvent.click(canvas.getByText(args.label!));
Expand Down Expand Up @@ -168,3 +169,34 @@ export const TestDisabledDoesNotOpenFlatpickr: MtDatepickerStory = {
expect((canvas.getByRole("textbox") as HTMLInputElement).disabled).toBe(true);
},
};

export const TestManualInput: MtDatepickerStory = {
name: "Should emit date value when manually typed",
args: {
label: "Date value",
dateType: "date",
modelValue: null,
},
play: async ({ canvasElement, args }) => {
const canvas = within(canvasElement);
const input = canvas.getByRole("textbox");

// Focus input
await userEvent.click(input);

// Clear input
await userEvent.clear(input);

// Enter date manually
await userEvent.type(input, "2024-12-24");

// Click label to close datepicker
await userEvent.click(canvas.getByText(args.label!));

// Expect input value
expect((input as HTMLInputElement).value).toBe("2024-12-24");

// Expect input event is triggered
expect(args.updateModelValue).toHaveBeenCalledWith("2024-12-24T00:00:00");
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,8 @@ export default defineComponent({
this.isDatepickerOpen = true;
});
this.flatpickrInstance.config.onClose.push(() => {
this.flatpickrInstance.config.onClose.push((...args) => {
this.emitValue(args[1]);
this.isDatepickerOpen = false;
});
Expand Down
19 changes: 12 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading