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(field-label): add field label pattern #1031

Merged
merged 5 commits into from
Dec 9, 2020
Merged

Conversation

Westbrook
Copy link
Contributor

@Westbrook Westbrook commented Dec 2, 2020

Description

  • add field label pattern
  • update docs site to use this pattern rather than custom code
  • correct an issue in stealing focus after an overlay is closed

Preview available at: https://5fc853af5b61815cd54df3fd--spectrum-web-components.netlify.app

Related Issue

fixed #475

Motivation and Context

Labels are an important accessibility and usability tool.

How Has This Been Tested?

  • unit tests
  • visual regression tests
  • manual integration tests

Screenshots (if appropriate):

image
image
image
image

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@jnurthen
Copy link
Member

jnurthen commented Dec 3, 2020

Clicking the label should move focus to the associated form element. This works fine for the sp-textfield but doesn't seem to work for the sp-dropdown

@Westbrook
Copy link
Contributor Author

@jnurthen thanks for checking in. Can you confirm a couple of things for me?

  • browser/os/version
  • if you "click the label" and then "press spacebar" does it act as expected with the sp-dropdown?

If yes to the spacebar, then this has to do with "click" not triggering the heuristic for :focus-visible. Should we be attempting to hack that in this case? If so, I can share this information with the Spectrum team so that this design/functionality can be perpetuated across other surfaces.

@jnurthen
Copy link
Member

jnurthen commented Dec 3, 2020

This occurred on both Safari & Chrome (Current production versions) on MacOS 10.15.7
You are correct that focus does indeed appear to be there - but the ring is not being drawn.

react-spectrum ( https://react-spectrum.adobe.com/react-spectrum/Picker.html ) does draw the focus ring in this case and I suggest that SWC should do the same.

@Westbrook
Copy link
Contributor Author

Haha. Gotta love the way the web has to motivate entire swaths of designers, devs and product owners to get an accessible feature into the platform only to work around its presence later.

Thanks for the clarification. I'll get that worked out and added to the PR.

I'll still bring this up with Spectrum design/CSS as the quite picker does this by default and there should really be a less bumpy design API here. Always a little something more!

Copy link
Collaborator

@adixon-adobe adixon-adobe left a comment

Choose a reason for hiding this comment

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

I don't have time to git this a really deep review, but this looks good overall.

I've got one comment that could be improved now (or later). I don't think you need to block this on it though.

if (!this.hasAttribute('id')) {
this.setAttribute(
'id',
`sp-field-label-${FieldLabel.instanceCount++}`
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is the sort of code that will cause subtle conflicts if multiple sp-field-label classes can be instantiated, or if this is subclassed. Can you use the tag name directly here? That'd at least give some safety here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great idea. Updated!

@Westbrook Westbrook force-pushed the westbrook/field-label branch 2 times, most recently from 38ec0fd to cb744a1 Compare December 8, 2020 20:01
@Westbrook
Copy link
Contributor Author

Expanded on the tests here, and really hope we can get this reviewed/merged soon!

Copy link
Collaborator

@najikahalsema najikahalsema left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@Westbrook Westbrook merged commit 31e6fdf into next Dec 9, 2020
@Westbrook Westbrook deleted the westbrook/field-label branch December 9, 2020 03:56
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.

4 participants