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

Add uswds combo box #1373

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open

Add uswds combo box #1373

wants to merge 18 commits into from

Conversation

oleksii-morgun
Copy link
Contributor

@oleksii-morgun oleksii-morgun commented Oct 24, 2024

Chromatic

https://add-uswds-combo-box--65a6e2ed2314f7b8f98609d8.chromatic.com

Description

Related to department-of-veterans-affairs/vets-design-system-documentation#3154

Designs https://www.figma.com/design/uddjxccqvUyz5FSg1aD5wi/ZFeat---Triage-Group-Selection-Flows?node-id=1804-73207&node-type=canvas&t=Rhhpivvbmxpw3vw2-0

USWDS combobox: https://designsystem.digital.gov/components/combo-box/

QA Checklist

  • Component maintains 1:1 parity with design mocks
  • Text is consistent with what's been provided in the mocks
  • Component behaves as expected across breakpoints
  • Accessibility expert has signed off on code changes (if applicable. If not applicable provide reason why)
  • Designer has signed off on changes (if applicable. If not applicable provide reason why)
  • Tab order and focus state work as expected
  • Changes have been tested against screen readers (if applicable. If not applicable provide reason why)
  • New components are covered by e2e tests; updates to existing components are covered by existing test suite
  • Changes have been tested in vets-website using Verdaccio (if applicable. If not applicable provide reason why)

Screenshots

Acceptance criteria

  • QA checklist has been completed
  • Screenshots have been attached that cover desktop and mobile screens

Definition of done

  • Documentation has been updated, if applicable
  • A link has been provided to the originating GitHub issue (or connected to it via ZenHub)

@oleksii-morgun oleksii-morgun marked this pull request as ready for review October 31, 2024 20:01
@oleksii-morgun oleksii-morgun requested a review from a team as a code owner October 31, 2024 20:01
@jamigibbs jamigibbs added the minor For a minor Semantic Version change label Nov 1, 2024
@jamigibbs jamigibbs requested a review from a team November 1, 2024 13:19
Copy link
Contributor

@jamigibbs jamigibbs left a comment

Choose a reason for hiding this comment

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

Thank you so much @oleksii-morgun for working on this! This is going to be a really nice addition to the component library. I've just left a few questions and comments for discussion. I've also tagged our designer group to have a look too when they have a chance. 🙇🏼‍♀️

onChange={e => this.handleChange(e)}
disabled={disabled}
>
{this.populateOptions()}
Copy link
Contributor

@jamigibbs jamigibbs Nov 1, 2024

Choose a reason for hiding this comment

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

The spacing for the dropdown options don't match USWDS. Are we able to sync that up with their style module?

It also looks like our input has rounded corners but they are square.

Storybook

Screenshot 2024-11-01 at 9 13 22 AM

USWDS Example*

Screenshot 2024-11-01 at 9 13 06 AM

@import '../../mixins/uswds-input-width.scss';
@import '../../mixins/uswds-error-border.scss';


Copy link
Contributor

Choose a reason for hiding this comment

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

We diverge a little bit with USWDS and use a yellow border on focus instead of blue so we'll want to do that with the combobox as well.

Here is an example of the yellow focus border on va-input:

Screenshot 2024-11-01 at 9 17 01 AM

We have a mixin that you can import here should make that update for you:

@import '../../mixins/focusable.css';

);
});

it('renders disabled', async () => {
Copy link
Contributor

@jamigibbs jamigibbs Nov 1, 2024

Choose a reason for hiding this comment

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

At a minimum we'd like to see a test for every prop and custom event for the component. That means I'd expect a minimum of 12 or so tests here but I only see 7. Do you mind beefing up these tests a little bit more?


/**
* @componentName Combo Box
* @maturityCategory dont_use
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this should be Use With Caution: Candidate? 🤔

Screenshot 2024-11-01 at 9 22 40 AM

Here are the guidelines for the maturity scale.

The Use With Caution: Candidate requirements say:

  • Design System Team and/or Design System Council have evaluated the proposal.
  • The Design System Team will be creating documentation for the component or pattern.
  • The component or pattern may be in limited use (i.e. it may have already been shipped by a team). This could also be known as: “In work”, “Draft”, “Beta”, or “Give it a go! YMMV”.

Disabled.args = {
...defaultArgs,
value: 'elderberry',
disabled: true,
Copy link
Contributor

@jamigibbs jamigibbs Nov 1, 2024

Choose a reason for hiding this comment

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

I don't think we want to advertise that there is a disabled state. There are a11y concerns with this functionality.

Or maybe we don't want to have this functionality in the component at all? I will let the design and a11y reviewers weigh in on that though. cc @department-of-veterans-affairs/platform-design-system-designers @rsmithadhoc

Screenshot 2024-11-01 at 9 28 50 AM

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, our stance on disabled states is that instead of disabling something, just don't show it if it serves no purpose. I'm okay with leaving it in for parity with USWDS, but just not advertising it.

composed: true,
bubbles: true,
})
componentLibraryAnalytics: EventEmitter;
Copy link
Contributor

Choose a reason for hiding this comment

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

I've been advised previously by @jestutt from platform analytics that we should not add analytics code to a component until we have coordinated with her. So I think we should remove any custom analytics code for now and we'll create a follow-up ticket to get it added.

Unless @oleksii-morgun your team needs it for your user testing?

}
const inputElement = this.el.shadowRoot.querySelector('input');
if (inputElement && this.error) {
inputElement.classList.add('usa-input--error');
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you mind explaining a little more why displaying the error needs to be done in a component lifecycle instead of just using conditional markup in the render?

const labelElement = this.el.shadowRoot.querySelector('label');
if (comboBoxElement) {
comboBox.init(comboBoxElement, labelElement);
comboBox.on(comboBoxElement);
Copy link
Contributor

@jamigibbs jamigibbs Nov 1, 2024

Choose a reason for hiding this comment

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

I'm not sure I understand why the label needs to be added in this way instead of just in the markup. Do you mind clarifying?

forceUpdate(this.el);
});
if (!this.label) {
throw new Error('va-combo-box: label is a required property');
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure about this approach for throwing an Error on required props. 🤔 Generally we will just allow the markup for the prop to display or not display.

action: 'change',
details: {
label: this.label,
selectLabel: this.value,
Copy link
Contributor

Choose a reason for hiding this comment

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

Analytics will need to be coordinated with @jestutt before we can add this.

@oleksii-morgun
Copy link
Contributor Author

@jamigibbs thank you for a thorough review. I will have to get back to this the following week as I am out next week. And will look deeper into your suggestions.

@rsmithadhoc
Copy link
Contributor

rsmithadhoc commented Nov 7, 2024

I'll have to give this a test with our accessibility testing criteria, which I'll try to get to today or tomorrow, thanks! Edit: actively taking a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor For a minor Semantic Version change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants