Skip to content

Conversation

@TarunAdobe
Copy link
Contributor

@TarunAdobe TarunAdobe commented Jul 19, 2023

Updated the Number field increase/decrease buttons to use the number fields label as part of their label text

Description

Previously the number field increase/decrease buttons were using hardcoded labels as Increment/Decrement but now with this update buttons label text would use the number-field-label text as a part of it to give more context and clarity.

So for

<sp-field-label for="units">Package width</sp-field-label>
<sp-number-field
    id="units"
    style="width: 200px"
    value="4"
    format-options='{
        "style": "unit",
        "unit": "inch",
        "unitDisplay": "long"
    }'
></sp-number-field>

The buttons would have their labels as "Increase Package width" and "Decrease Package Width".

Related issue(s)

Motivation and context

How has this been tested?

  • Test case 1
    1. Go here
    2. Do this
  • Test case 2
    1. Go here
    2. Do this

Screenshots (if appropriate)

Types of changes

  • [x ] 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.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 19, 2023

Tachometer results

Chrome

number-field permalink

Version Bytes Avg Time vs remote vs branch
npm latest 625 kB 228.52ms - 233.67ms - faster ✔
0% - 3%
0.38ms - 7.49ms
branch 626 kB 232.58ms - 237.48ms slower ❌
0% - 3%
0.38ms - 7.49ms
-

search permalink

Version Bytes Avg Time vs remote vs branch
npm latest 469 kB 115.90ms - 117.44ms - unsure 🔍
-5% - +2%
-5.69ms - +2.50ms
branch 468 kB 114.24ms - 122.28ms unsure 🔍
-2% - +5%
-2.50ms - +5.69ms
-

slider permalink

Version Bytes Avg Time vs remote vs branch
npm latest 452 kB 162.57ms - 166.80ms - unsure 🔍
-2% - +2%
-2.76ms - +2.74ms
branch 453 kB 162.94ms - 166.44ms unsure 🔍
-2% - +2%
-2.74ms - +2.76ms
-

textfield permalink

Version Bytes Avg Time vs remote vs branch
npm latest 416 kB 68.97ms - 70.42ms - unsure 🔍
-2% - +1%
-1.42ms - +0.64ms
branch 416 kB 69.35ms - 70.81ms unsure 🔍
-1% - +2%
-0.64ms - +1.42ms
-
Firefox

number-field permalink

Version Bytes Avg Time vs remote vs branch
npm latest 625 kB 423.64ms - 448.76ms - faster ✔
4% - 11%
20.01ms - 51.51ms
branch 626 kB 462.46ms - 481.46ms slower ❌
4% - 12%
20.01ms - 51.51ms
-

search permalink

Version Bytes Avg Time vs remote vs branch
npm latest 469 kB 203.63ms - 228.33ms - unsure 🔍
-11% - +2%
-25.88ms - +5.48ms
branch 468 kB 216.52ms - 235.84ms unsure 🔍
-3% - +12%
-5.48ms - +25.88ms
-

slider permalink

Version Bytes Avg Time vs remote vs branch
npm latest 452 kB 341.34ms - 362.46ms - unsure 🔍
-4% - +5%
-12.91ms - +16.87ms
branch 453 kB 339.43ms - 360.41ms unsure 🔍
-5% - +4%
-16.87ms - +12.91ms
-

textfield permalink

Version Bytes Avg Time vs remote vs branch
npm latest 416 kB 148.02ms - 166.18ms - unsure 🔍
-3% - +15%
-4.20ms - +21.48ms
branch 416 kB 139.38ms - 157.54ms unsure 🔍
-13% - +2%
-21.48ms - +4.20ms
-

Rajdeepc
Rajdeepc previously approved these changes Jul 19, 2023
Copy link
Contributor

@Rajdeepc Rajdeepc left a comment

Choose a reason for hiding this comment

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

LGTM!

@Westbrook
Copy link
Contributor

Please review the failing tests in this branch.

@TarunAdobe
Copy link
Contributor Author

@Westbrook Here's some explanation for these changes... I'd love to get your opinion on this.
So in the FieldLabel we have this function applyTargetLabel which we use to apply target label to other components. Now let's say we talk about number-field component. In that we have the focusable set as the input so the label of input is applied automatically from the applyTargetLabel function. We also wanted to have labels on the buttons but the buttons are not focusable (the input is). Thus is we use a separate helper function that is provided namely applyFocusElementLabel then according to the older conditions we will never apply the label to the focusable element. Thus I modified the if/else such that it would always run the applyLabel function if it is provided by the component and on top of that it will do other house keeping tasks like applying label to the focus element. I wanna understand if this is the correct way to do this? Thnx.
(Refer to latest changes for better understanding)

@TarunAdobe
Copy link
Contributor Author

updated the logic such that textField takes care of setting up the labels on the input properly

Copy link
Contributor

@Westbrook Westbrook left a comment

Choose a reason for hiding this comment

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

This change is looking good, just some small clean up remains.

Together with that, please take a look at this test and include a similar one here to support preventing regressions in this area going forward.

@TarunAdobe
Copy link
Contributor Author

updated the code to add a test and fixed the code styling issues @Westbrook

Copy link
Contributor

@Westbrook Westbrook left a comment

Choose a reason for hiding this comment

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

This looks great. Thanks for adding the test.

@Westbrook Westbrook force-pushed the issue/number-field-labels branch from 9c139a9 to 118da9c Compare July 21, 2023 11:49
@Westbrook Westbrook merged commit b92daf2 into main Jul 21, 2023
@Westbrook Westbrook deleted the issue/number-field-labels branch July 21, 2023 11:50
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.

[Bug]: sp-number-field Increment/Decrement button labels

4 participants