Skip to content

Commit a8d077b

Browse files
authored
Merge pull request #290 from silinternational/develop
Release 11.6.0 - Add clear button to SearchableSelect, bump deps
2 parents 6641816 + 8f3aeae commit a8d077b

File tree

4 files changed

+123
-123
lines changed

4 files changed

+123
-123
lines changed

CHANGELOG.md

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,37 @@
22
All notable changes to this project will be documented in this file.
33
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), enforced with [semantic-release](https://github.com/semantic-release/semantic-release).
44

5-
## [11.5.0](https://github.com/silinternational/ui-components/compare/v11.4.2...v11.5.0) (2024-09-09)
5+
## [11.6.0](https://github.com/silinternational/ui-components/compare/v11.5.0...v11.6.0) (2024-10-03)
66

77

88
### Added
99

10-
* **DateInput:** add data-1p-ignore to prevent 1Password trying to fill ([c296811](https://github.com/silinternational/ui-components/commit/c29681127222afabceff914350aafebe38687dfc))
11-
* **MoneyInput:** add data-1p-ignore to prevent 1Password trying to fill ([6367aa8](https://github.com/silinternational/ui-components/commit/6367aa8f43c5544556039feaf848fff60002cf33))
12-
* **SearchableSelect:** add data-1p-ignore to SearchableSelect ([ce4bf4b](https://github.com/silinternational/ui-components/commit/ce4bf4be28a7c3ef5efe0636c47d4437e8fe71f0))
13-
* **Select:** add data-1p-ignore to prevent 1Password trying to fill ([1e502e2](https://github.com/silinternational/ui-components/commit/1e502e226144bf0c8b41a7535f8499d62df537e7))
10+
* **SearchableSelect:** add clear button to SearchableSelect ([000f776](https://github.com/silinternational/ui-components/commit/000f776dc36dd7e7c2bd10363d6314c5ed0fae5b))
1411

15-
### [11.4.2](https://github.com/silinternational/ui-components/compare/v11.4.1...v11.4.2) (2024-09-06)
1612

13+
### Changed
14+
15+
* **changelog:** format ([3fd0539](https://github.com/silinternational/ui-components/commit/3fd05396879a911d075855c92828eaf4a06f2265))
16+
17+
# Changelog
18+
19+
All notable changes to this project will be documented in this file.
20+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), enforced with [semantic-release](https://github.com/semantic-release/semantic-release).
21+
22+
## [11.5.0](https://github.com/silinternational/ui-components/compare/v11.4.2...v11.5.0) (2024-09-09)
23+
24+
### Added
25+
26+
- **DateInput:** add data-1p-ignore to prevent 1Password trying to fill ([c296811](https://github.com/silinternational/ui-components/commit/c29681127222afabceff914350aafebe38687dfc))
27+
- **MoneyInput:** add data-1p-ignore to prevent 1Password trying to fill ([6367aa8](https://github.com/silinternational/ui-components/commit/6367aa8f43c5544556039feaf848fff60002cf33))
28+
- **SearchableSelect:** add data-1p-ignore to SearchableSelect ([ce4bf4b](https://github.com/silinternational/ui-components/commit/ce4bf4be28a7c3ef5efe0636c47d4437e8fe71f0))
29+
- **Select:** add data-1p-ignore to prevent 1Password trying to fill ([1e502e2](https://github.com/silinternational/ui-components/commit/1e502e226144bf0c8b41a7535f8499d62df537e7))
30+
31+
### [11.4.2](https://github.com/silinternational/ui-components/compare/v11.4.1...v11.4.2) (2024-09-06)
1732

1833
### Fixed
1934

20-
* **Drawer:** fix A11y warning in Drawer ([275d2b9](https://github.com/silinternational/ui-components/commit/275d2b9f0944e82da7b275f043afc11b6e9296c1))
35+
- **Drawer:** fix A11y warning in Drawer ([275d2b9](https://github.com/silinternational/ui-components/commit/275d2b9f0944e82da7b275f043afc11b6e9296c1))
2136

2237
### [11.4.1](https://github.com/silinternational/ui-components/compare/v11.4.0...v11.4.1) (2024-07-09)
2338

components/custom/SearchableSelect/SearchableSelect.svelte

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export let showError = false
2323
2424
let element = {}
2525
let randomId = generateRandomID('dataList-')
26+
let savedChoice = ''
2627
2728
const dispatch = createEventDispatcher()
2829
@@ -32,6 +33,18 @@ const onChange = (e) => {
3233
choice = internalChoice
3334
element.blur()
3435
}
36+
37+
const clearChoice = () => {
38+
savedChoice = choice
39+
choice = ''
40+
}
41+
42+
const onBlur = () => {
43+
if (savedChoice && !choice) {
44+
choice = savedChoice
45+
}
46+
dispatch('check', choice)
47+
}
3548
</script>
3649

3750
<style>
@@ -80,6 +93,16 @@ const onChange = (e) => {
8093
border-color: var(--mdc-theme-status-error, var(--mdc-theme-error));
8194
color: var(--mdc-theme-status-error, var(--mdc-theme-error));
8295
}
96+
97+
.clear-button {
98+
cursor: pointer;
99+
padding: 5px;
100+
position: relative;
101+
right: 50px;
102+
border-radius: 4px;
103+
border: none;
104+
background-color: transparent;
105+
}
83106
</style>
84107

85108
<label class="custom-field" style="--field-padding: {padding}; {$$props.class || ''}">
@@ -98,11 +121,14 @@ const onChange = (e) => {
98121
value={choice}
99122
on:change={onChange}
100123
on:change
101-
on:blur={(e) => dispatch('check', e.target.value)}
124+
on:blur={onBlur}
102125
on:blur
103126
on:focus
104127
/>
105128
<span class="placeholder">{placeholder}</span>
129+
{#if choice}
130+
<button type="button" class="clear-button" on:click={clearChoice} aria-label="Clear selection">✕</button>
131+
{/if}
106132
</label>
107133

108134
<datalist id={randomId}>

0 commit comments

Comments
 (0)