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

fix(number-field): select full value when using Tab to enter a field with a unit #4340

Merged
merged 1 commit into from
May 24, 2024

Conversation

Westbrook
Copy link
Contributor

Description

Keyboard based focus of Number Fields with units should select all of the available content.

Related issue(s)

How has this been tested?

  • Test case 1
    1. Go here
    2. Use Tab to focus the Number Field, see that all of the content is selected
  • Test case 2
    1. Go here
    2. Click to focus the Number Field
    3. See that there is no selection in the Number Field

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

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.

@Westbrook Westbrook requested a review from a team April 29, 2024 18:52
Copy link

github-actions bot commented Apr 29, 2024

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:

Copy link

github-actions bot commented Apr 29, 2024

Lighthouse scores

Category Latest (report) Main (report) Branch (report)
Performance 0.99 0.99 0.99
Accessibility 1 1 1
Best Practices 1 1 1
SEO 1 0.92 0.92
PWA 1 1 1
What is this?

Lighthouse scores comparing the documentation site built from the PR ("Branch") to that of the production documentation site ("Latest") and the build currently on main ("Main"). Higher scores are better, but note that the SEO scores on Netlify URLs are artifically constrained to 0.92.

Transfer Size

Category Latest Main Branch
Total 221.05 kB 210.404 kB 210.169 kB 🏆
Scripts 53.31 kB 48.19 kB 47.999 kB 🏆
Stylesheet 34.854 kB 30.317 kB 🏆 30.381 kB
Document 5.892 kB 5.291 kB 5.193 kB 🏆
Font 126.994 kB 126.606 kB 126.596 kB 🏆

Request Count

Category Latest Main Branch
Total 45 45 45
Scripts 37 37 37
Stylesheet 5 5 5
Document 1 1 1
Font 2 2 2

Copy link

github-actions bot commented Apr 29, 2024

Tachometer results

Chrome

color-field permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 487 kB 41.06ms - 42.27ms - faster ✔
2% - 7%
1.04ms - 3.00ms
branch 475 kB 42.91ms - 44.46ms slower ❌
2% - 7%
1.04ms - 3.00ms
-

combobox permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 709 kB 36.49ms - 37.52ms - faster ✔
3% - 6%
1.11ms - 2.52ms
branch 697 kB 38.33ms - 39.30ms slower ❌
3% - 7%
1.11ms - 2.52ms
-

light-dom-test permalink

Version Bytes Avg Time vs remote vs branch
npm latest 709 kB 398.81ms - 406.75ms - faster ✔
3% - 7%
13.82ms - 29.87ms
branch 697 kB 417.65ms - 431.60ms slower ❌
3% - 7%
13.82ms - 29.87ms
-

number-field permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 523 kB 67.29ms - 68.90ms - faster ✔
10% - 13%
7.43ms - 10.08ms
branch 511 kB 75.80ms - 77.90ms slower ❌
11% - 15%
7.43ms - 10.08ms
-

search permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 471 kB 39.24ms - 40.53ms - faster ✔
3% - 7%
1.17ms - 3.01ms
branch 459 kB 41.32ms - 42.63ms slower ❌
3% - 8%
1.17ms - 3.01ms
-

slider permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 480 kB 75.57ms - 78.47ms - faster ✔
2% - 6%
1.50ms - 5.15ms
branch 467 kB 79.23ms - 81.45ms slower ❌
2% - 7%
1.50ms - 5.15ms
-

textfield permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 432 kB 24.21ms - 24.95ms - faster ✔
8% - 12%
2.28ms - 3.40ms
branch 420 kB 27.00ms - 27.84ms slower ❌
9% - 14%
2.28ms - 3.40ms
-
Firefox

color-field permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 495 kB 75.84ms - 78.08ms - faster ✔
1% - 5%
0.77ms - 3.91ms
branch 483 kB 78.20ms - 80.40ms slower ❌
1% - 5%
0.77ms - 3.91ms
-

combobox permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 709 kB 64.25ms - 70.87ms - slower ❌
7% - 18%
4.10ms - 10.94ms
branch 697 kB 59.17ms - 60.91ms faster ✔
7% - 16%
4.10ms - 10.94ms
-

light-dom-test permalink

Version Bytes Avg Time vs remote vs branch
npm latest 709 kB 712.10ms - 736.46ms - slower ❌
3% - 6%
18.01ms - 43.83ms
branch 697 kB 689.09ms - 697.63ms faster ✔
3% - 6%
18.01ms - 43.83ms
-

number-field permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 523 kB 144.13ms - 150.31ms - faster ✔
6% - 12%
9.02ms - 19.58ms
branch 511 kB 157.24ms - 165.80ms slower ❌
6% - 13%
9.02ms - 19.58ms
-

search permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 471 kB 67.32ms - 73.12ms - faster ✔
1% - 12%
0.56ms - 8.84ms
branch 459 kB 71.97ms - 77.87ms slower ❌
1% - 13%
0.56ms - 8.84ms
-

slider permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 480 kB 162.21ms - 169.35ms - unsure 🔍
-5% - +1%
-8.87ms - +0.95ms
branch 467 kB 166.37ms - 173.11ms unsure 🔍
-1% - +5%
-0.95ms - +8.87ms
-

textfield permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 432 kB 48.84ms - 53.60ms - faster ✔
3% - 16%
1.52ms - 9.12ms
branch 420 kB 53.58ms - 59.50ms slower ❌
3% - 18%
1.52ms - 9.12ms
-

@Westbrook Westbrook force-pushed the number-field-selection branch 8 times, most recently from f462bcb to effd80f Compare May 6, 2024 19:02
@Westbrook Westbrook force-pushed the number-field-selection branch 4 times, most recently from ecbec82 to 7973c41 Compare May 10, 2024 12:40
@@ -355,6 +357,7 @@ export class TextfieldBase extends ManageHelpText(
.value=${live(this.displayValue)}
@change=${this.handleChange}
@input=${this.handleInput}
@pointerdown=${this.handleInputElementPointerdown}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it's an annoyance of the class extension system and templating that this is required but the idea is definitely that by default Textfield does nothing for pointer down events and then in NumberField it does something specific. It implies the benefit of a alternative composition techniques within these render methods, but that's a huge alternative project with unclear benefits and risks.


protected override handleInputElementPointerdown(): void {
this.hasRecentlyReceivedPointerDown = true;
this.updateComplete.then(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Won't this cause a delay in the event to complete?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a reaction to the event having been triggered. Because it is in the promise (updateComplete) it will release the thread during the event and wait till the promise releases before reengaging the workflow.

!!this.formatOptions.unit
) {
// Normalize keyboard focus entry between unit and non-unit bearing Number Fields
this.setSelectionRange(0, this.displayValue.length);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to check if displayValue has a length or not right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

displayValue is always a string, and even if it's length is 0 the outcome here will still be correct.

@@ -355,6 +357,7 @@ export class TextfieldBase extends ManageHelpText(
.value=${live(this.displayValue)}
@change=${this.handleChange}
@input=${this.handleInput}
@pointerdown=${this.handleInputElementPointerdown}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it's an annoyance of the class extension system and templating that this is required but the idea is definitely that by default Textfield does nothing for pointer down events and then in NumberField it does something specific. It implies the benefit of a alternative composition techniques within these render methods, but that's a huge alternative project with unclear benefits and risks.

@Westbrook Westbrook force-pushed the number-field-selection branch 2 times, most recently from 14387f6 to 851f1c4 Compare May 10, 2024 13:59
@Westbrook Westbrook requested a review from Rajdeepc May 10, 2024 15:12
@Westbrook Westbrook force-pushed the number-field-selection branch 2 times, most recently from 1b3aba5 to 65a3f30 Compare May 22, 2024 11:35
@Westbrook Westbrook merged commit a9d5cef into main May 24, 2024
20 of 57 checks passed
@Westbrook Westbrook deleted the number-field-selection branch May 24, 2024 15:52
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.

[Feat]: Select all the contents of the spectrum number field when doing a tab switch.
3 participants