-
Notifications
You must be signed in to change notification settings - Fork 0
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
SCC-4384: My Account 2.0 VQA/a11y round 1 #412
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
238e363
VQA fixes
7emansell 3f41f55
Start of accessibility focus work
7emansell 5cd827d
Labelling corrections
7emansell c7c18f2
Adding a bunch of refs
7emansell 7d58c93
Associating delete message with button
7emansell 7be3cf9
Updating tests with new explicitly numbered labels
7emansell 4d6a400
And username test
7emansell 612e027
Reducing refs and styling corrections
7emansell 54e1d81
More alignment
7emansell 182416b
More minor tweaking
7emansell 3221114
Fully focus
7emansell 1820027
Adding tests for focus
7emansell 46c071b
Correcting inputRefs behavior
7emansell 905c5da
Explicitly typing the string for save cancel buttons
7emansell b44aff5
Bringing back multiple refs, currently an issue with clearableCallback
7emansell 664cf93
Testing focus
7emansell 90f7041
Removing isClearable from input fields
7emansell 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
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 |
---|---|---|
@@ -1,30 +1,36 @@ | ||
import { Button } from "@nypl/design-system-react-components" | ||
import { forwardRef } from "react" | ||
|
||
type AddButtonProps = { | ||
inputType?: string | ||
label: string | ||
onClick: () => void | ||
} | ||
|
||
const AddButton = ({ inputType, label, onClick }: AddButtonProps) => { | ||
return ( | ||
<Button | ||
id={inputType ? `add-${inputType}-button` : "add-button"} | ||
buttonType="text" | ||
onClick={onClick} | ||
size="large" | ||
sx={{ | ||
justifyContent: "flex-start", | ||
width: { base: "100%", md: "300px" }, | ||
paddingLeft: { base: "m", md: "unset" }, | ||
paddingTop: "xs", | ||
paddingBottom: "xs", | ||
paddingRight: "xs", | ||
}} | ||
> | ||
{label} | ||
</Button> | ||
) | ||
} | ||
const AddButton = forwardRef<HTMLButtonElement, AddButtonProps>( | ||
({ inputType, label, onClick }, ref) => { | ||
return ( | ||
<Button | ||
ref={ref} | ||
id={inputType ? `add-${inputType}-button` : "add-button"} | ||
buttonType="text" | ||
onClick={onClick} | ||
size="large" | ||
sx={{ | ||
justifyContent: "flex-start", | ||
width: { base: "100%", md: "300px" }, | ||
paddingLeft: "xs", | ||
paddingTop: "xs", | ||
paddingBottom: "xs", | ||
paddingRight: "xs", | ||
}} | ||
> | ||
{label} | ||
</Button> | ||
) | ||
} | ||
) | ||
|
||
AddButton.displayName = "AddButton" | ||
|
||
export default AddButton |
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 |
---|---|---|
@@ -1,26 +1,36 @@ | ||
import { Button, Icon } from "@nypl/design-system-react-components" | ||
import { forwardRef } from "react" | ||
|
||
type EditButtonProps = { | ||
buttonId: string | ||
buttonLabel: string | ||
onClick: () => void | ||
} | ||
|
||
const EditButton = ({ buttonId, onClick }: EditButtonProps) => { | ||
return ( | ||
<Button | ||
id={buttonId} | ||
buttonType="text" | ||
onClick={onClick} | ||
sx={{ | ||
paddingLeft: "xs", | ||
paddingRight: "xs", | ||
marginLeft: "xxl", | ||
}} | ||
> | ||
<Icon name="editorMode" align="left" size="medium" /> | ||
Edit | ||
</Button> | ||
) | ||
} | ||
const EditButton = forwardRef<HTMLButtonElement, EditButtonProps>( | ||
({ buttonLabel, buttonId, onClick }, ref) => { | ||
return ( | ||
<Button | ||
ref={ref} | ||
id={buttonId} | ||
aria-label={buttonLabel} | ||
buttonType="text" | ||
onClick={onClick} | ||
sx={{ | ||
marginTop: { base: "unset", lg: "-xs" }, | ||
paddingTop: "0", | ||
paddingBottom: "0", | ||
paddingLeft: "xs", | ||
paddingRight: "xs", | ||
}} | ||
> | ||
<Icon name="editorMode" align="left" size="medium" /> | ||
Edit | ||
</Button> | ||
) | ||
} | ||
) | ||
|
||
EditButton.displayName = "EditButton" | ||
|
||
export default EditButton |
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 |
---|---|---|
|
@@ -48,7 +48,9 @@ describe("email form", () => { | |
render(component) | ||
fireEvent.click(screen.getByRole("button", { name: /edit/i })) | ||
|
||
expect(screen.getAllByLabelText("Update emails")[0]).toBeInTheDocument() | ||
expect( | ||
screen.getByLabelText("Update primary email address") | ||
).toBeInTheDocument() | ||
expect( | ||
screen.getByDisplayValue("[email protected]") | ||
).toBeInTheDocument() | ||
|
@@ -60,12 +62,37 @@ describe("email form", () => { | |
expect(screen.queryByText(/edit/)).not.toBeInTheDocument() | ||
}) | ||
|
||
it("manages focus", async () => { | ||
render(component) | ||
fireEvent.click(screen.getByRole("button", { name: /edit/i })) | ||
|
||
await waitFor(() => | ||
expect(screen.getByLabelText("Update email address 2")).toHaveFocus() | ||
) | ||
|
||
fireEvent.click(screen.getByRole("button", { name: /cancel/i })) | ||
|
||
await waitFor(() => | ||
expect(screen.getByRole("button", { name: /edit/i })).toHaveFocus() | ||
) | ||
|
||
fireEvent.click(screen.getByRole("button", { name: /edit/i })) | ||
|
||
fireEvent.click(screen.getByText("+ Add an email address")) | ||
|
||
await waitFor(() => expect(screen.getAllByRole("textbox")[2]).toHaveFocus()) | ||
|
||
fireEvent.click(screen.getAllByLabelText("Remove email")[1]) | ||
|
||
await waitFor(() => expect(screen.getAllByRole("textbox")[1]).toHaveFocus()) | ||
}) | ||
|
||
it("validates email input correctly", () => { | ||
render(component) | ||
|
||
fireEvent.click(screen.getByRole("button", { name: /edit/i })) | ||
|
||
const input = screen.getAllByLabelText("Update emails")[0] | ||
const input = screen.getByLabelText("Update primary email address") | ||
fireEvent.change(input, { target: { value: "invalid-email" } }) | ||
|
||
expect( | ||
|
@@ -84,7 +111,7 @@ describe("email form", () => { | |
screen.getByRole("button", { name: /\+ add an email address/i }) | ||
) | ||
|
||
expect(screen.getAllByLabelText("Update emails").length).toBe( | ||
expect(screen.getAllByRole("textbox").length).toBe( | ||
processedPatron.emails.length + 1 | ||
) | ||
}) | ||
|
@@ -106,7 +133,7 @@ describe("email form", () => { | |
|
||
fireEvent.click(screen.getByRole("button", { name: /edit/i })) | ||
|
||
const input = screen.getAllByLabelText("Update emails")[0] | ||
const input = screen.getByLabelText("Update primary email address") | ||
fireEvent.change(input, { target: { value: "[email protected]" } }) | ||
|
||
fireEvent.click(screen.getByRole("button", { name: /save changes/i })) | ||
|
@@ -128,7 +155,7 @@ describe("email form", () => { | |
|
||
fireEvent.click(screen.getByRole("button", { name: /edit/i })) | ||
|
||
const input = screen.getAllByLabelText("Update emails")[0] | ||
const input = screen.getByLabelText("Update primary email address") | ||
fireEvent.change(input, { target: { value: "[email protected]" } }) | ||
|
||
fireEvent.click(screen.getByRole("button", { name: /cancel/i })) | ||
|
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
Oops, something went wrong.
Oops, something went wrong.
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.
👍