Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Open
wants to merge 11 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 grid-template-columns: 1fr 80px; to the host level
    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

⚠️ No Changeset found

Latest commit: 3eef905

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a 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]) .input {
padding-inline-end: calc(
Copy link
Contributor Author

@caseyisonit caseyisonit Apr 3, 2025

Choose a reason for hiding this comment

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

This addresses the icon overlapping the input value/truncation when invalid. This is not an issue for valid. The calc is copied from the valid input CSS.


: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

Currently, no packages are changed by this PR...

@@ -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.


## States

Use the `required` attribute to indicate a number field value is required. Dictate the validity or invalidity state of the text entry with the `valid` or `invalid` attributes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

copy pasta'd from text field. this readme is still on the docs audit list so didn't do a full pass.

@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 not 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

…b.com:adobe/spectrum-web-components into caseyisonit/swc-669-number-field-icon-overlap
@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

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
3 participants