adobe / spectrum-web-components

Spectrum Web Components
https://opensource.adobe.com/spectrum-web-components/
Apache License 2.0
1.21k stars 192 forks source link

chore(search): added logic to hold search value on escape #4528

Closed Rajdeepc closed 4 weeks ago

Rajdeepc commented 1 month ago

Background

The current implementation uses type="search" on the input element, causing the search value to be cleared whenever the ESC key is pressed. This default behavior is not always desirable.

Objective

To provide an API that allows users to determine whether the search value should be retained when the ESC key is pressed. This will be achieved through a new property holdValueOnEscape.

Implementation Details

Property Introduction: A new Boolean property holdValueOnEscape is introduced. When set to true, the typeattribute of the input element is set to 'text', preventing the default behavior of clearing the input value on ESC.

Default Behavior: By default, holdValueOnEscape is true, ensuring the value is retained when ESC is pressed. Conditionally Setting Type: In the firstUpdated lifecycle method, the type attribute of the input element is conditionally set to 'text' based on the holdValueOnEscape property.

Related issue(s)

-

Motivation and context

How has this been tested?

Screenshots (if appropriate)

Types of changes

Checklist

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[bot] commented 1 month ago

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: - [High Contrast Mode | Medium | LTR](https://4bd5de4f5dda93b0b49add6bdf00c056--spectrum-web-components.netlify.app/review/) - [Spectrum | Lightest | Medium | LTR](https://38fddf6308e179c7f34633e68146b49c--spectrum-web-components.netlify.app/review/) - [Spectrum | Lightest | Medium | RTL](https://828859e61cda80dc33dc5247483df8e9--spectrum-web-components.netlify.app/review/) - [Spectrum | Lightest | Large | LTR](https://68feb74d828dc74e26b1d9f6b7ba5b84--spectrum-web-components.netlify.app/review/) - [Spectrum | Lightest | Large | RTL](https://dc81db37a2552d8271f2ab65c12cc32c--spectrum-web-components.netlify.app/review/) - [Spectrum | Light | Medium | LTR](https://8bad25bc7bc7a96c6fadd33bcaf450aa--spectrum-web-components.netlify.app/review/) - [Spectrum | Light | Medium | RTL](https://b9fbd50cb32aad6de742fed88d270868--spectrum-web-components.netlify.app/review/) - [Spectrum | Light | Large | LTR](https://5bcf1f8a3662cba7b5031c94e69191b1--spectrum-web-components.netlify.app/review/) - [Spectrum | Light | Large | RTL](https://863c43c98fc701fed0a90edde619c353--spectrum-web-components.netlify.app/review/) - [Spectrum | Dark | Medium | LTR](https://5e9a8479152f06f6e428c6a07ab490f9--spectrum-web-components.netlify.app/review/) - [Spectrum | Dark | Medium | RTL](https://f05e23bcb725463bb86553e8d5095d1b--spectrum-web-components.netlify.app/review/) - [Spectrum | Dark | Large | LTR](https://7e412a103740c779c26dfc4033b7baaa--spectrum-web-components.netlify.app/review/) - [Spectrum | Dark | Large | RTL](https://16f1e741907e8b91913702a9e04cecfb--spectrum-web-components.netlify.app/review/) - [Spectrum | Darkest | Medium | LTR](https://f142390cdaa611eeb0f61c917d3244c7--spectrum-web-components.netlify.app/review/) - [Spectrum | Darkest | Medium | RTL](https://7d6c07ab6858e62499974c4b3bcbb403--spectrum-web-components.netlify.app/review/) - [Spectrum | Darkest | Large | LTR](https://d63588b06c2c561223d511c21a0579ac--spectrum-web-components.netlify.app/review/) - [Spectrum | Darkest | Large | RTL](https://4df9a3344df52105d760b09a2a091d69--spectrum-web-components.netlify.app/review/) - [Express | Lightest | Medium | LTR](https://a27ae444514a7b4cefed28e52415f4d7--spectrum-web-components.netlify.app/review/) - [Express | Lightest | Medium | RTL](https://ad75805c30eec7adc09ebbf0dac9d657--spectrum-web-components.netlify.app/review/) - [Express | Lightest | Large | LTR](https://42f3dd4e15ef1b5e19ca68595a578ec4--spectrum-web-components.netlify.app/review/) - [Express | Lightest | Large | RTL](https://0961b4fe17ddfcd2ca841e84acb8a6f7--spectrum-web-components.netlify.app/review/) - [Express | Light | Medium | LTR](https://b8156ab2174bd6a7f14f55be50d49c7e--spectrum-web-components.netlify.app/review/) - [Express | Light | Medium | RTL](https://4426dd211bdbce3bb2b5606b2ca08525--spectrum-web-components.netlify.app/review/) - [Express | Light | Large | LTR](https://5582665042b2b5292033f402eb3d8e47--spectrum-web-components.netlify.app/review/) - [Express | Light | Large | RTL](https://64d630767cd48036bb7efee5fcbad052--spectrum-web-components.netlify.app/review/) - [Express | Dark | Medium | LTR](https://14702924bc467eb6e96ddc9862ca435b--spectrum-web-components.netlify.app/review/) - [Express | Dark | Medium | RTL](https://70eca8bbf70fb333f580d71f39e624ea--spectrum-web-components.netlify.app/review/) - [Express | Dark | Large | LTR](https://62b8ef31092cbe71520f16118cc8da2f--spectrum-web-components.netlify.app/review/) - [Express | Dark | Large | RTL](https://f791528fd8e0e1c3897ac410a7a45ee1--spectrum-web-components.netlify.app/review/) - [Express | Darkest | Medium | LTR](https://ae32bc600e7088f100123ec4708600cf--spectrum-web-components.netlify.app/review/) - [Express | Darkest | Medium | RTL](https://34a0ea123e49f981750f5434bf30dd8b--spectrum-web-components.netlify.app/review/) - [Express | Darkest | Large | LTR](https://218c566c92fc0d37e5c2ff5ae5bd9f2c--spectrum-web-components.netlify.app/review/) - [Express | Darkest | Large | RTL](https://43031ce9279f4d1a4f643ac01085c807--spectrum-web-components.netlify.app/review/) - [Spectrum-two | Light | Medium | LTR](https://6ff77662b0492b05f418c20f325688b6--spectrum-web-components.netlify.app/review/) - [Spectrum-two | Light | Medium | RTL](https://67dccf3d768fac3f1c3a43d6d91060a9--spectrum-web-components.netlify.app/review/) - [Spectrum-two | Light | Large | LTR](https://0d3da36f23d950dc80f424407a17eb78--spectrum-web-components.netlify.app/review/) - [Spectrum-two | Light | Large | RTL](https://2ff92f6dec900c877e27230d7b4ac051--spectrum-web-components.netlify.app/review/) - [Spectrum-two | Dark | Medium | LTR](https://50b2b6821f4a597c8bf99b25adfedeaa--spectrum-web-components.netlify.app/review/) - [Spectrum-two | Dark | Medium | RTL](https://f611bf6008e9d0a42e1955d92c2b2c0e--spectrum-web-components.netlify.app/review/) - [Spectrum-two | Dark | Large | LTR](https://70348ca209a065094d7f25e3740aa69e--spectrum-web-components.netlify.app/review/) - [Spectrum-two | Dark | Large | RTL](https://5eacf33bc5e7012b7f8b7cd286967003--spectrum-web-components.netlify.app/review/)
github-actions[bot] commented 1 month ago

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](https://github.com/GoogleChrome/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 222.586 kB 210.736 kB 🏆 210.775 kB
Scripts 54.539 kB 48.482 kB 48.354 kB 🏆
Stylesheet 35.052 kB 30.302 kB 🏆 30.487 kB
Document 5.98 kB 5.347 kB 5.31 kB 🏆
Font 127.015 kB 126.605 kB 🏆 126.624 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
github-actions[bot] commented 1 month ago

Tachometer results

Chrome ## search [_permalink_](#user-content-search) ### test-basic | Version | Bytes | Avg Time | vs remote | vs branch | |---|---|---|---|---| | npm latest | 472 kB | 39.27ms - 39.99ms | - | faster ✔
4% - 6%
1.64ms - 2.67ms | | branch | 459 kB | 41.42ms - 42.15ms | slower ❌
4% - 7%
1.64ms - 2.67ms | - |
Firefox ## search [_permalink_](#user-content-search) ### test-basic | Version | Bytes | Avg Time | vs remote | vs branch | |---|---|---|---|---| | npm latest | 472 kB | 72.02ms - 78.18ms | - | unsure 🔍
-8% - +1%
-6.57ms - +0.97ms | | branch | 459 kB | 75.71ms - 80.09ms | unsure 🔍
-1% - +9%
-0.97ms - +6.57ms | - |