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

feat: added CC Field #420

Merged
merged 2 commits into from
Aug 29, 2023
Merged

feat: added CC Field #420

merged 2 commits into from
Aug 29, 2023

Conversation

Fredx87
Copy link
Contributor

@Fredx87 Fredx87 commented Aug 22, 2023

Description

This PR adds a CC field to the new request form.

We decided to implement a custom component since Garden doesn't have a component that fits our use case.

In theory, it would be possible to use a Combobox, but the UX is not optimal since it doesn't make much sense to show a popup with suggested results when the user can input any value they want, and there isn't a set of predefined values.

The implementation resembles the existing component, and it is also similar to an example shown in the ARIA Authoring Practices Guide website, where the list of recipients in rendered in a grid. For this reason, I used the grid container from Garden.

I tested the component with VoiceOver on Safari and NVDA on Firefox, but we'll need to wait for an A11Y audit to refine it and ensure it is properly accessible.

Keyboard interaction

  • It is possible to enter a new e-mail and press Enter, Tab, Space, or Comma to add it to the CC list
  • It is possible to move from the input to the CC list and back using Tab/Shift+Tab
  • It is possible to move inside the CC list using arrow keys
  • It is possible to delete a recipient by pressing Backspace when it is focused

Screen reader

  • When an e-mail is added or removed there is an aria-live region that announces "[e-mail] has been added" or "[e-mail] has been removed"
  • When the grid containing the list of CC is focused, the screen reader reads the label ("Selected CC e-mails") and describes it as a grid that can be navigated with the arrow keys
  • When a recipient is focused, it says "Press Backspace to remove" and "invalid data" if the e-mail is invalid

Other notes:

  • Like the previous implementation, it is possible to paste a list of e-mails separated by spaces, commas, or semicolons and they will be added to the list
  • When an e-mail is invalid it is added to the list, but shown with a red background and not saved in the ticket. This is probably not accessible, and we should find a way to make it more clear that an e-mail is invalid
  • The implementation is divided into a "container" hook which contains the logic related to A11Y, and a component for the UI. This is similar to the pattern used by Garden (even if it is a bit simplified), and ideally, the container can be ported to Garden and reused elsewhere.
  • Since the CC field is available only for some users and only when a specific setting is enabled, it is lazy loaded.

Screenshots

Screen.Recording.2023-08-22.at.10.54.07.mov

Checklist

  • 📗 all commit messages follow the conventional commits standard
  • ⬅️ changes are compatible with RTL direction
  • ♿ Changes to the UI are tested for accessibility and compliant with WCAG 2.1.
  • 📝 changes are tested in Chrome, Firefox, Safari and Edge
  • 📱 changes are responsive and tested in mobile
  • 👍 PR is approved by @zendesk/vikings

@Fredx87 Fredx87 requested a review from a team as a code owner August 22, 2023 09:13
Copy link
Contributor

@sergioazevedo sergioazevedo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a frontend expert ;) but it looks good to me.

);
}

const Container = styled(FauxInput)`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: would be nice to be consistent and always define variables/functions either at the top or bottom of the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree. I personally think that the file is easier to read if the main exported component is on top, and the rest on the bottom. But since we used the opposite convention in other files, I will follow that. Maybe we can revisit it later

{/* Used to automatically resize the input based on the content */}
<InputMirror isBare aria-hidden="true" tabIndex={-1}>
{/* When the input is empty we show a space, otherwise the height of the mirror is less than the input */}
{inputValue || " "}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: we've had issues with white space not existing/being supported in asian languages. Not sure if this case is even a problem but if it could be easily addressed with CSS that could be better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll give another try to see if it is fixable with CSS only

case "cc_email":
return (
<Suspense fallback={<></>}>
<CcField field={field} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point we might need some error handling when lazy loading, e.g. providing a regular text field that asks for emails separated by ,. In that case, it might be better to not lazy load here. No need to address now though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if it makes sense to have a functional fallback component because we would need to support 2 different implementations. For example, with the regular text field, we would still need to parse the value and create some hidden inputs to submit the values.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree it's maybe it's overkill for error handling 👍🏼
Let's see how large the js payloads will become. I'm thinking that in some extreme use case, e.g. Disney we might need to do some optimization and that may mean offering "smaller" components. Just something to keep in mind for later.

Copy link
Contributor

@luis-almeida luis-almeida left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼 🚀

@Fredx87 Fredx87 merged commit e1a4ce3 into v4-alpha Aug 29, 2023
2 checks passed
@Fredx87 Fredx87 deleted the gianluca/cc-field-grid branch August 29, 2023 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants