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

2244 ic date input improve deletion of full date via keyboard #3239

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
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,30 @@ describe("IcDateInput end-to-end, visual regression and a11y tests", () => {
cy.findShadowEl(DATE_INPUT, YEAR_INPUT_ARIA_LABEL).should(HAVE_VALUE, "");
});

it("should test deleting the date using backspace", () => {
mount(<IcDateInput label="Test Label" />);

cy.checkHydrated(DATE_INPUT);

cy.findShadowEl(DATE_INPUT, DAY_INPUT_ARIA_LABEL).type("30");
cy.findShadowEl(DATE_INPUT, MONTH_INPUT_ARIA_LABEL).type("04");
cy.findShadowEl(DATE_INPUT, YEAR_INPUT_ARIA_LABEL).type("2000");

cy.findShadowEl(DATE_INPUT, YEAR_INPUT_ARIA_LABEL).type(
"{Backspace}{Backspace}{Backspace}{Backspace}"
);
cy.findShadowEl(DATE_INPUT, MONTH_INPUT_ARIA_LABEL).type(
"{Backspace}{Backspace}"
);
cy.findShadowEl(DATE_INPUT, DAY_INPUT_ARIA_LABEL).type(
"{Backspace}{Backspace}"
);

cy.findShadowEl(DATE_INPUT, DAY_INPUT_ARIA_LABEL).should(HAVE_VALUE, "");
cy.findShadowEl(DATE_INPUT, MONTH_INPUT_ARIA_LABEL).should(HAVE_VALUE, "");
cy.findShadowEl(DATE_INPUT, YEAR_INPUT_ARIA_LABEL).should(HAVE_VALUE, "");
});

it("should enter complete date and check for accessibility", () => {
mount(
<div style={{ padding: "10px" }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,12 @@ export class DateInput {
this.preventAutoFormatting = true;
this.handleUpDownArrowKeyPress(input, event);
break;
case "backspace":
if (input.value.length === 0) {
event.preventDefault();
this.moveToPreviousInput(input);
}
break;
default:
break;
}
Expand Down
Loading