Skip to content

fix(number-field): sp-number-field UI fixes for validation and width #5326

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

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

Conversation

caseyisonit
Copy link
Contributor

@caseyisonit caseyisonit commented Apr 3, 2025

Description

Number Field had a number of issues related to the UI, default widths, and token modifiers. This PR addresses the following:

  • Validation icons rendering over the infield buttons
  • Exposing a width modifying token for the number field
  • Reintroducing the default widths for the various sizes of the number field
  • Ensuring that the number field renders correctly in a grid, as seen in slider [editable]

Related issue(s)

Motivation and context

Number Field should be customizable, have a default width based on design docs, and have validation icons and input truncation render correctly.

How has this been tested?

  • _Review the VRTs and ensure no unexpected side effects happen in other components

    1. I will update the golden hash once others have reviewed the diffs
  • Check validation icons render correctly

    1. Go here
    2. Icons should not overlap infield buttons
    3. Type a long number in the valid & invalid inputs and the number should truncate before the icon
  • Check you can modify the width via mod token

    1. Go here
    2. Inspect sp-number-field in dev tools
    3. add --mod-stepper-width: 500px to the host level
    4. see visual change
  • Check you can modify the width via width

    1. Go here
    2. Inspect sp-number-field in dev tools
    3. add width: 500px to the host level
    4. see visual change
  • Slider [editable] number field should fill the available grid column

    1. Go here
    2. Inspect sp-slider in dev tools
    3. With inspect arrow active, hover over the sp-slider dom node
    4. see no gap in the available space after the number field
  • Slider [editable] number field should size correctly when grid column is modified

    1. Go here
    2. Inspect sp-slider in dev tools
    3. add --mod-stepper-width: 80px; to the slider
    4. number field should be 80px
  • Did it pass in Desktop?

  • Did it pass in Mobile?

  • Did it pass in iPad?

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (minor updates related to the tooling or maintenance of the repository, does not impact compiled assets)

Checklist

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • If my change required a change to the documentation, I have updated the documentation in this pull request.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have reviewed at the Accessibility Practices for this feature, see: Aria Practices

Best practices

This repository uses conventional commit syntax for each commit message; note that the GitHub UI does not use this by default so be cautious when accepting suggested changes. Avoid the "Update branch" button on the pull request and opt instead for rebasing your branch against main.

Copy link

changeset-bot bot commented Apr 3, 2025

🦋 Changeset detected

Latest commit: d851a52

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

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

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

Copy link

github-actions bot commented Apr 3, 2025

Branch preview

Review the following VRT differences

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

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.


:host([invalid]:not([hide-stepper])) #textfield .icon {
--mod-textfield-icon-spacing-inline-end-invalid: calc(
var(--system-infield-button-top-width) +
Copy link
Contributor Author

Choose a reason for hiding this comment

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

wasn't sure if there was a better token to use for the width of the stepper buttons to use in the calc

Copy link

github-actions bot commented Apr 3, 2025

Tachometer results

Chrome

number-field permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 627 kB 71.63ms - 73.08ms - faster ✔
9% - 12%
7.48ms - 9.81ms
branch 578 kB 80.09ms - 81.91ms slower ❌
10% - 14%
7.48ms - 9.81ms
-

textfield permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 524 kB 24.65ms - 26.02ms - faster ✔
9% - 15%
2.66ms - 4.52ms
branch 461 kB 28.30ms - 29.56ms slower ❌
10% - 18%
2.66ms - 4.52ms
-
Firefox

number-field permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 627 kB 157.37ms - 162.67ms - faster ✔
5% - 9%
8.08ms - 16.00ms
branch 578 kB 169.12ms - 175.00ms slower ❌
5% - 10%
8.08ms - 16.00ms
-

textfield permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 524 kB 48.18ms - 51.54ms - faster ✔
5% - 15%
2.60ms - 8.44ms
branch 461 kB 52.99ms - 57.77ms slower ❌
5% - 17%
2.60ms - 8.44ms
-

@@ -13,6 +13,9 @@ governing permissions and limitations under the License.
@import url('./spectrum-number-field.css');
@import url('./number-field-overrides.css');

:host {
inline-size: unset;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sp-text-field sets an inline-size on the host, which causes side effects for sp-slider that uses number-field. This unsets the inline size and resolves the issue PSWeb called out on sp-slider [editable].

Fun fact: number-field extends textFieldBase, so moving forward, any changes to the text field will need to cross-check the number field heavily.

@caseyisonit caseyisonit marked this pull request as ready for review April 7, 2025 18:36
@caseyisonit caseyisonit requested a review from a team as a code owner April 7, 2025 18:36
@nikkimk
Copy link
Contributor

nikkimk commented Apr 7, 2025

iii. add --mod-stepper-width: 500px to the host level

@caseyisonit In the testing instructions, for modifying with mod token, should we remove the style="width: 150px" first?

@@ -13,6 +13,41 @@ governing permissions and limitations under the License.
@import url('./spectrum-number-field.css');
@import url('./number-field-overrides.css');

:host {
Copy link
Contributor

@nikkimk nikkimk Apr 7, 2025

Choose a reason for hiding this comment

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

NIT: @caseyisonit do you want to make a note about the PR that removed this and why it is being added back in?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes! great callout!

This block was removed in a fast-follow but broke the default sizing or number field along with removing the modifiable width on number-field. This is not delivered from CSS and thus needs to remain in our stylesheet.

Copy link
Contributor

@nikkimk nikkimk left a comment

Choose a reason for hiding this comment

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

Update the golden images hash, respond to my comment on testing instructions to clarify to the next reviewer, reply to my comment in the code review for future us, and then LGTM

@caseyisonit
Copy link
Contributor Author

Update the golden images hash, respond to my comment on testing instructions to clarify to the next reviewer, reply to my comment in the code review for future us, and then LGTM

I forgot to push up my last changes let me do that and ill update the golden hash after

@caseyisonit caseyisonit changed the title fix(number-field, slider): sp-number-field icon overlaping buttons and fixed sizing issue in sp-slider editable fix(number-field): sp-number-field UI fixes for validation and width Apr 7, 2025
@caseyisonit
Copy link
Contributor Author

@marissahuysentruyt is going to review for CSS tomorrow morning, golden hash will be updated AFTER with a changeset

Copy link
Collaborator

@marissahuysentruyt marissahuysentruyt left a comment

Choose a reason for hiding this comment

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

Way to stick with this one- glad you hunted this down! To me, this is looking good. I had a few questions, but don't think I currently have any "changes" to request. I'll wait to hear back on those questions, and then I'm happy to approve!

Copy link
Collaborator

@marissahuysentruyt marissahuysentruyt left a comment

Choose a reason for hiding this comment

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

Mainly more questions for you!

I went down a little rabbit hold with the invalid border colors. Could that be a separate PR, or does it relate close enough to the validation work you were doing? 🤷‍♀️

@castastrophe castastrophe force-pushed the caseyisonit/swc-669-number-field-icon-overlap branch from f815251 to 385e353 Compare April 18, 2025 18:06
@caseyisonit
Copy link
Contributor Author

TODO: post cutoff we should fix the infield buttons error border color on express, this is present in production so it's out of scope for this PR

@castastrophe castastrophe force-pushed the caseyisonit/swc-669-number-field-icon-overlap branch from a537b09 to 972e022 Compare April 24, 2025 20:33
@castastrophe castastrophe force-pushed the caseyisonit/swc-669-number-field-icon-overlap branch 3 times, most recently from c13e2fa to 2dab297 Compare April 24, 2025 21:01
@castastrophe castastrophe force-pushed the caseyisonit/swc-669-number-field-icon-overlap branch from 2dab297 to d851a52 Compare April 24, 2025 21:22
@castastrophe castastrophe force-pushed the caseyisonit/swc-669-number-field-icon-overlap branch from d851a52 to 88f2105 Compare April 24, 2025 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants