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

Stepper Input #3347

Merged
merged 50 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
80b24d2
use core formfield in stories
lilyvc Apr 30, 2024
c141390
update prop types
lilyvc Apr 30, 2024
dd0e0b7
remove styling
lilyvc Apr 30, 2024
0640f44
prettier
lilyvc Apr 30, 2024
959ab2f
fix type error
lilyvc Apr 30, 2024
241b834
extend input types
lilyvc May 1, 2024
a87daa0
spread all props to stepper input
lilyvc May 1, 2024
47b3d89
remove unnecessary function call
lilyvc May 1, 2024
ea9f55c
use chevrons and half buttons
lilyvc May 1, 2024
f80aec4
typechecks
lilyvc May 1, 2024
bb1abfd
Merge branch 'main' into stepper-input
lilyvc May 1, 2024
b9a5069
reduce spacing and increase button size
lilyvc May 1, 2024
09cfea2
update tests
lilyvc May 1, 2024
c559454
fix imports
lilyvc May 2, 2024
a57144b
use add remove icons
lilyvc May 2, 2024
07b1a8d
remove extra functionality
lilyvc May 3, 2024
f5d5845
update tests
lilyvc May 8, 2024
7f873f6
update qa stories
lilyvc May 8, 2024
09d45f3
Update packages/lab/src/__tests__/__e2e__/stepper-input/StepperInput.…
lilyvc May 8, 2024
9f6f1de
stack buttons
lilyvc May 9, 2024
c1949bf
add changeset
lilyvc May 9, 2024
de45e45
Merge branch 'main' into stepper-input
lilyvc May 9, 2024
02bf07c
address review comments
lilyvc May 9, 2024
14290ac
use event.target
lilyvc May 10, 2024
1e3ee00
move buttons outside
lilyvc May 14, 2024
8c05ccd
add hidebuttons prop and extend input props
lilyvc May 16, 2024
04b29de
add custom increment buttons example
lilyvc May 16, 2024
ff09de1
add secondary example
lilyvc May 16, 2024
23f7a6d
add step to decimal places example
lilyvc May 16, 2024
86f78c8
omit unsupported props
lilyvc May 16, 2024
f6d218d
simplify directions
lilyvc May 16, 2024
668edd4
update changeset
lilyvc May 16, 2024
c004b88
use secondary button
lilyvc May 16, 2024
6a2943b
add validation to min max example
lilyvc May 16, 2024
5f4eee3
add width to validated example
lilyvc May 16, 2024
61b1d11
show error state if out of range
lilyvc May 17, 2024
0fc406c
use label in tests, call onmouseup directly, add disabled qa stories
lilyvc May 20, 2024
75791f6
add more tests
lilyvc May 20, 2024
24be4ce
remove error validation
lilyvc May 21, 2024
1cf3f12
Merge branch 'main' into stepper-input
lilyvc May 21, 2024
9a859b6
correct hidebutton to hidebuttons
lilyvc May 21, 2024
c43b828
Merge branch 'main' into stepper-input
lilyvc May 22, 2024
0a7d48e
support read only
lilyvc May 22, 2024
bee7b3d
add readonly and disabled to qa
lilyvc May 22, 2024
fbf09fc
Merge branch 'main' into stepper-input
lilyvc May 22, 2024
4234e8e
use props id
lilyvc May 22, 2024
4d4877b
update syntax
lilyvc May 22, 2024
7900f1a
Merge branch 'main' into stepper-input
lilyvc May 23, 2024
3c40955
Merge branch 'main' into stepper-input
lilyvc May 23, 2024
69f9c0f
Merge branch 'main' into stepper-input
lilyvc May 23, 2024
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
6 changes: 6 additions & 0 deletions .changeset/gold-windows-deliver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@salt-ds/lab": minor
---

Removed `liveValue`, `showRefreshButton`, `ButtonProps` and `InputProps` props from `StepperInput`.
Added `hideButtons` prop from `StepperInput` and updated to extend Input's `InputProps`.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { StepperInput, FormField } from "@salt-ds/lab";
import { useState } from "react";
import { StepperInput } from "@salt-ds/lab";
import { FormField, FormFieldHelperText, FormFieldLabel } from "@salt-ds/core";

describe("Stepper Input - Accessibility", () => {
it("sets the correct default ARIA attributes on input", () => {
Expand All @@ -20,95 +20,17 @@ describe("Stepper Input - Accessibility", () => {

it("has the correct labelling when wrapped in a `FormField`", () => {
cy.mount(
<FormField helperText="please enter a value" label="stepper input">
<FormField>
<FormFieldLabel>Stepper Input</FormFieldLabel>
<StepperInput defaultValue={-10} min={0} />
<FormFieldHelperText>Please enter a value</FormFieldHelperText>
</FormField>
);

cy.findByRole("spinbutton").should("have.accessibleName", "stepper input");
cy.findByRole("spinbutton").should("have.accessibleName", "Stepper Input");
cy.findByRole("spinbutton").should(
"have.accessibleDescription",
"please enter a value"
);
});

it("appends a message to `aria-label` when the controlled `liveValue` prop changes", () => {
const ControlledLiveValue = () => {
const [liveValue, setLiveValue] = useState(10);

return (
<>
<FormField helperText="please enter a value" label="stepper input">
<StepperInput defaultValue={10} liveValue={liveValue} />
</FormField>
<button
onClick={() => setLiveValue((prev) => prev + 1)}
type="button"
>
Increment
</button>
</>
);
};

cy.mount(<ControlledLiveValue />);

cy.findByRole("spinbutton").should("have.accessibleName", "stepper input");
cy.findByRole("spinbutton").should(
"have.accessibleDescription",
"please enter a value"
);

cy.findByRole("button", { name: "Increment" }).realClick();

cy.findByRole("spinbutton").should(
"have.accessibleName",
"stepper input , value out of date"
);
cy.findByRole("spinbutton").should(
"have.accessibleDescription",
"please enter a value"
);
});

it("removes the appended message from `aria-label` when the the component is refreshed", () => {
const ControlledLiveValue = () => {
const [liveValue, setLiveValue] = useState(11);

return (
<>
<FormField helperText="please enter a value" label="stepper input">
<StepperInput defaultValue={10} liveValue={liveValue} />
</FormField>
<button
onClick={() => setLiveValue((prev) => prev + 1)}
type="button"
>
Increment
</button>
</>
);
};

cy.mount(<ControlledLiveValue />);

cy.findByRole("button", { name: "Increment" }).realClick();

cy.findByRole("spinbutton").should(
"have.accessibleName",
"stepper input , value out of date"
);
cy.findByRole("spinbutton").should(
"have.accessibleDescription",
"please enter a value"
);

cy.findByRole("button", { name: "Refresh default value" }).realClick();

cy.findByRole("spinbutton").should("have.accessibleName", "stepper input");
cy.findByRole("spinbutton").should(
"have.accessibleDescription",
"please enter a value"
"Please enter a value"
);
});

Expand All @@ -119,11 +41,11 @@ describe("Stepper Input - Accessibility", () => {

it("sets the correct default ARIA attributes on the increment/decrement buttons", () => {
cy.mount(<StepperInput />);
cy.findByTestId("increment-button")
cy.findByLabelText("increment value")
.should("have.attr", "tabindex", "-1")
.and("have.attr", "aria-hidden", "true");

cy.findByTestId("decrement-button")
cy.findByLabelText("decrement value")
.should("have.attr", "tabindex", "-1")
.and("have.attr", "aria-hidden", "true");
});
Expand Down
Loading
Loading