Skip to content

Conversation

@nikkimk
Copy link
Contributor

@nikkimk nikkimk commented Nov 6, 2025

Description

Field label

  • Added src/FieldLabelMixin.ts to render field label within a component's shadow DOM.
  • Added field-label-mixin.md to document the mixin.
  • Updated package.json to include field mixin.

Textfield

  • Updated README.md docs to include slotted label and examples.
  • Updated package.json to include field label dependency.
  • Updated src/Textfield.ts to use the field label mixin to render field label.
  • Updated stories/textarea-sizes.stories.ts to include slotted label.
  • Updated stories/textarea.stories.ts to include slotted label.
  • Updated stories/textfield-sizes.stories.ts to include slotted label.
  • Updated stories/textfield.stories.ts to include slotted label.
  • Updated test/textfield-a11y.test.ts to test for slotted label.

Color Field

Color field extends textfield so its shadow DOM will also have a field label.

  • Updated README.md docs to include slotted label and examples.
  • Updated stories/color-field-sizes.stories.ts to include slotted label.

Number field

Number field extends textfield so its shadow DOM will also have a field label.

  • Updated README.md docs to include slotted label and examples.
  • Updated stories/number-field-sizes.stories.ts to include slotted label.
  • Updated stories/number-field.stories.ts to include slotted label.

Combobox

  • Updated README.md docs to include slotted label and examples.
  • Updated package.json to include field label dependency.
  • Updated src/Combobox.ts to use the field label mixin to render field label.
  • Updated stories/combobox.stories.ts to use the slotted label.
  • Updated stories/index.ts to use the slotted label.
  • Updated test/combobox-a11y.test.ts to test for slotted label.

Motivation and context

Create a FormFieldMixin component to standardize form field behavior across Spectrum Web Components. This refactor will improve consistency and reduce code duplication by extracting common form field functionality into a reusable mixin. The implementation will use checkbox and textfield components as test cases to validate the mixin's functionality.

Related issue(s)

  • fixes SWC-1042
  • fixes SWC-1044
  • fixes SWC-1045
  • fixes SWC-1046

Screenshots (if appropriate)


Author's checklist

  • I have read the CONTRIBUTING and PULL_REQUESTS documents.
  • I have reviewed at the Accessibility Practices for this feature, see: Aria Practices
  • I have added automated tests to cover my changes.
  • I have included a well-written changeset if my change needs to be published.
  • I have included updated documentation if my change required it.

Reviewer's checklist

  • Includes a Github Issue with appropriate flag or Jira ticket number without a link
  • Includes thoughtfully written changeset if changes suggested include patch, minor, or major features
  • Automated tests cover all use cases and follow best practices for writing
  • Validated on all supported browsers
  • All VRTs are approved before the author can update Golden Hash

Manual review test cases

  • Descriptive Test Statement

    1. Go here
    2. Do this action
    3. Expect this result
  • Descriptive Test Statement

    1. Go here
    2. Do this action
    3. Expect this result

Device review

  • Did it pass in Desktop?
  • Did it pass in (emulated) Mobile?
  • Did it pass in (emulated) iPad?

* feat(label): init field label mixin

feat(label): init field label mixin

* feat(textfield): updated textfiled docs to use label mixin

* feat(field-label): added mixin to package exports

* feat(field-label): added optional slot name for rendering label slot

* docs(textfield): implemented label mixin in stories

* test(textfield): added test for slotted label

* feat(textfield): added default slot observer for label changes

* test(textfield): added tests for slotted label

* docs(number-field): updated number field docs based on text field label changes

* docs(number-field): updated stories with slotted label

* docs(color-field): updated docs with slotted label

* feat(field-label): updated interface to include optional slot name for label

* feat(combobox): added label slot to combobox

* docs(combobox): added slotted label to docs

* test(combobox): updates tests with slotted label

* fix(combobox): fixed combobox field id for label

* feat(field-label): added label slot change handler to mixin

* feat(combobox): added slot change handlers

* feat(field-label): hide field label if not used

* feat(textfield): use field label mixin to observe slot

* feat(combobox): use field label mixin to observe slot

* feat(combobox): added placeholder

* fix(textfield): fixed issue with detecting slot content

* fix(field-label): fixed issue with slot content detection in text field

* test(textfield): removed unneccessary id attribute

* fix(fieldl-label): fixed mixin to allow slot naming

* feat(combobox): updated combobox, stories and tests for field label mixin

* fix(field-label): corrected linting issues

* fix(menu): MenuItem focus stealing from input elements on mouseover (#5732)

* fix(menu): added check to find focused element within root context

* fix(menu): added story

* fix(menu): added test

* chore(menu): added changeset

* fix(menu): added global const for component input pattern

* fix(menu): remove delimiter from the regexp constructor

* chore: skipped prod and vrt tests on the new story

* chore: fix tests helpers

* fix: check for cross root boundary

* fix: code comments

---------

Co-authored-by: Rajdeep Chandra <rajdeepchandra@Rajdeeps-MacBook-Pro-6.local>
Co-authored-by: Rajdeep Chandra <rajdeepchandra@rajdeeps-mbp-7.macromedia.com>
Co-authored-by: Rajdeep Chandra <rajdeepchandra@Rajdeeps-MacBook-Pro-7.local>

* fix(field-label): made field id optional for picker

* fix(field-label): made field id optional for picker

* feat(picker): added field label mixin to pciker and picker stories

* fix(textfiled): fixed element name in warning

* fix(combobox): fixed element name in warning

* docs(picker): updated stories

* feat(picker): added field label mizin to picker without affecting pickerBase

* docs(textfield): documented default label slot

* feat(picker): reverting changes until picker is refactored

* feat(picker): reverting changes until picker is refactored

* feat(picker): reverting changes until picker is refactored

* feat(picker): reverting changes until picker is refactored

* feat(picker): reverting changes until picker is refactored

* feat(picker): reverting changes until picker is refactored

* feat(picker): reverting changes until picker is refactored

* feat(picker): reverting changes until picker is refactored

* feat(picker): reverting changes until picker is refactored

* feat(picker): reverting changes until picker is refactored

* docs(textfield): updated docs with label examples

* docs(textfield): fixed issue with tabs

* test(textfield): updated test warning text to match revised warning text

* docs(combobox): added label and placeholder sections to docs

* docs(textfield): changed tabs label

* docs(number-field): updated docs with a label section

* chore(changeset): added changsets

* docs(field-label): added field-label-mixin docs

* Apply suggestion from @nikkimk

* feat(picker): revert changes

* feat(picker): revert changes

* chore: updated changesets

* docs(color-field): added label docs

* chore: updated changesets

* docs(combobox): fixed typo

Co-authored-by: Casey Eickhoff <48574582+caseyisonit@users.noreply.github.com>

* docs(field-label): added JS Docs to mixin

* chore: linting fixes

* docs(combobox): fixed typo

Co-authored-by: Casey Eickhoff <48574582+caseyisonit@users.noreply.github.com>

* chore: dropped changeset

* docs(color-field): fixed typo

Co-authored-by: Marissa Huysentruyt <69602589+marissahuysentruyt@users.noreply.github.com>

* chore(combobox): fixed typo

* docs(combobox): added side-aligned to story

* docs(combobox): fixed typo

Co-authored-by: Marissa Huysentruyt <69602589+marissahuysentruyt@users.noreply.github.com>

* docs(combobox): fixed typo

Co-authored-by: Marissa Huysentruyt <69602589+marissahuysentruyt@users.noreply.github.com>

* docs(field-label): added links to mixin docs

* docs(field-label): added code type in mixin docs

Co-authored-by: Marissa Huysentruyt <69602589+marissahuysentruyt@users.noreply.github.com>

* docs(field-label): added code type in mixin docs

Co-authored-by: Marissa Huysentruyt <69602589+marissahuysentruyt@users.noreply.github.com>

* fix(textfield): simiplified styles getter

* fix(textfield): simplified attribute

Co-authored-by: Rúben Carvalho <rubcar@sapo.pt>

* fix(textfield): simplified attribute

* docs(field-label): added more detail to mixin docs

Co-authored-by: Rúben Carvalho <rubcar@sapo.pt>

* docs(field-label): added more detail to field label mixin docs

Co-authored-by: Rúben Carvalho <rubcar@sapo.pt>

* fix(field-label): fixed inherited styles in mixin

Co-authored-by: Rúben Carvalho <rubcar@sapo.pt>

* fix(field-label): set side-aligned property to optional

Co-authored-by: Rúben Carvalho <rubcar@sapo.pt>

* fix(field-label): added override to styles getter

Co-authored-by: Rúben Carvalho <rubcar@sapo.pt>

* fix(field-label): field id should be required

* fix(field-label): reverted styles changes to mixin

* fix(textfield): fixed styles array

* fix(textfield): ensure super styles are CSSResultArray

---------

Co-authored-by: Rajdeep Chandra <rajrock38@gmail.com>
Co-authored-by: Rajdeep Chandra <rajdeepchandra@Rajdeeps-MacBook-Pro-6.local>
Co-authored-by: Rajdeep Chandra <rajdeepchandra@rajdeeps-mbp-7.macromedia.com>
Co-authored-by: Rajdeep Chandra <rajdeepchandra@Rajdeeps-MacBook-Pro-7.local>
Co-authored-by: Casey Eickhoff <48574582+caseyisonit@users.noreply.github.com>
Co-authored-by: Marissa Huysentruyt <69602589+marissahuysentruyt@users.noreply.github.com>
Co-authored-by: Rúben Carvalho <rubcar@sapo.pt>
@nikkimk nikkimk self-assigned this Nov 6, 2025
@changeset-bot
Copy link

changeset-bot bot commented Nov 6, 2025

🦋 Changeset detected

Latest commit: a61ad48

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 78 packages
Name Type
@spectrum-web-components/number-field Minor
@spectrum-web-components/field-label Minor
@spectrum-web-components/combobox Minor
@spectrum-web-components/textfield Minor
@spectrum-web-components/color-field Minor
@spectrum-web-components/slider Minor
@spectrum-web-components/bundle Minor
@spectrum-web-components/action-bar Minor
@spectrum-web-components/meter Minor
@spectrum-web-components/picker Minor
@spectrum-web-components/progress-bar Minor
@spectrum-web-components/search Minor
@spectrum-web-components/action-menu Minor
@spectrum-web-components/breadcrumbs Minor
@spectrum-web-components/accordion Minor
@spectrum-web-components/action-button Minor
@spectrum-web-components/action-group Minor
@spectrum-web-components/alert-banner Minor
@spectrum-web-components/alert-dialog Minor
@spectrum-web-components/asset Minor
@spectrum-web-components/avatar Minor
@spectrum-web-components/badge Minor
@spectrum-web-components/button-group Minor
@spectrum-web-components/button Minor
@spectrum-web-components/card Minor
@spectrum-web-components/checkbox Minor
@spectrum-web-components/clear-button Minor
@spectrum-web-components/close-button Minor
@spectrum-web-components/coachmark Minor
@spectrum-web-components/color-area Minor
@spectrum-web-components/color-handle Minor
@spectrum-web-components/color-loupe Minor
@spectrum-web-components/color-slider Minor
@spectrum-web-components/color-wheel Minor
@spectrum-web-components/contextual-help Minor
@spectrum-web-components/dialog Minor
@spectrum-web-components/divider Minor
@spectrum-web-components/dropzone Minor
@spectrum-web-components/field-group Minor
@spectrum-web-components/help-text Minor
@spectrum-web-components/icon Minor
@spectrum-web-components/icons-ui Minor
@spectrum-web-components/icons-workflow Minor
@spectrum-web-components/icons Minor
@spectrum-web-components/iconset Minor
@spectrum-web-components/illustrated-message Minor
@spectrum-web-components/infield-button Minor
@spectrum-web-components/link Minor
@spectrum-web-components/menu Minor
@spectrum-web-components/modal Minor
@spectrum-web-components/overlay Minor
@spectrum-web-components/picker-button Minor
@spectrum-web-components/popover Minor
@spectrum-web-components/progress-circle Minor
@spectrum-web-components/radio Minor
@spectrum-web-components/sidenav Minor
@spectrum-web-components/split-view Minor
@spectrum-web-components/status-light Minor
@spectrum-web-components/swatch Minor
@spectrum-web-components/switch Minor
@spectrum-web-components/table Minor
@spectrum-web-components/tabs Minor
@spectrum-web-components/tags Minor
@spectrum-web-components/thumbnail Minor
@spectrum-web-components/toast Minor
@spectrum-web-components/tooltip Minor
@spectrum-web-components/top-nav Minor
@spectrum-web-components/tray Minor
@spectrum-web-components/underlay Minor
@spectrum-web-components/base Minor
@spectrum-web-components/grid Minor
@spectrum-web-components/opacity-checkerboard Minor
@spectrum-web-components/reactive-controllers Minor
@spectrum-web-components/shared Minor
@spectrum-web-components/styles Minor
@spectrum-web-components/theme Minor
@spectrum-web-components/truncated Minor
@spectrum-web-components/eslint-plugin Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@nikkimk nikkimk added Status: WIP PR is a work in progress or draft do-not-merge NO MERGE-Y! labels Nov 7, 2025
@nikkimk nikkimk changed the title FormFieldMixin DO NOT MERGE: FormFieldMixin Nov 7, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 7, 2025

📚 Branch Preview

🔍 Visual Regression Test Results

When a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:

Deployed to Azure Blob Storage: pr-5864

If the changes are expected, update the current_golden_images_cache hash in the circleci config to accept the new images. Instructions are included in that file.
If the changes are unexpected, you can investigate the cause of the differences and update the code accordingly.

"component",
"css"
],
"dependencies": {
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ [eslint] <jsonc/sort-keys> reported by reviewdog 🐶
Expected object keys to be in specified order. 'dependencies' should be before 'keywords'.

reviewdog suggestion errorGitHub comment range and suggestion line range must be same. L66-L66 v.s. L53-L80

"@spectrum-web-components/shared": "1.10.0",
"@spectrum-web-components/textfield": "1.10.0"
},
"types": "./src/index.d.ts",
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ [eslint] <jsonc/sort-keys> reported by reviewdog 🐶
Expected object keys to be in specified order. 'types' should be before 'dependencies'.

reviewdog suggestion errorGitHub comment range and suggestion line range must be same. L81-L81 v.s. L53-L81

import { Combobox, ComboboxOption } from '@spectrum-web-components/combobox';
import '@spectrum-web-components/combobox/sp-combobox.js';
import '@spectrum-web-components/field-label/sp-field-label.js';
import { spreadProps } from '../../../test/lit-helpers';
Copy link
Contributor

Choose a reason for hiding this comment

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

🚫 [eslint] <require-extensions/require-extensions> reported by reviewdog 🐶
Relative imports and exports must end with .js

Suggested change
import { spreadProps } from '../../../test/lit-helpers';
import { spreadProps } from '../../../test/lit-helpers.js';

import { Combobox, ComboboxOption } from '@spectrum-web-components/combobox';
import '@spectrum-web-components/combobox/sp-combobox.js';
import '@spectrum-web-components/field-label/sp-field-label.js';
import { spreadProps } from '../../../test/lit-helpers';
Copy link
Contributor

Choose a reason for hiding this comment

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

🚫 [eslint] <import/extensions> reported by reviewdog 🐶
Missing file extension for "../../../test/lit-helpers"

"./src/index.js": {
"development": "./src/index.dev.js",
"default": "./src/index.js"
"./sp-field-label-mixin.js": {
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ [eslint] <jsonc/sort-keys> reported by reviewdog 🐶
Expected object keys to be in ascending order. './sp-field-label-mixin.js' should be before './src/field-label.css.js'.

reviewdog suggestion errorGitHub comment range and suggestion line range must be same. L38-L38 v.s. L27-L41

"component",
"css"
],
"dependencies": {
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ [eslint] <jsonc/sort-keys> reported by reviewdog 🐶
Expected object keys to be in specified order. 'dependencies' should be before 'keywords'.

reviewdog suggestion errorGitHub comment range and suggestion line range must be same. L66-L66 v.s. L53-L74

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge NO MERGE-Y! Status: WIP PR is a work in progress or draft

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants