|
82 | 82 | function changeSearchValue(e) { |
83 | 83 | searchValue = e.target.value || ''; |
84 | 84 | if (searchValue) { |
85 | | - innerOptions = refOptions.filter(x => x.value.includes(searchValue)); |
| 85 | + innerOptions = [...refOptions.filter(x => x.value.includes(searchValue))]; |
86 | 86 | } else { |
87 | | - innerOptions = refOptions; |
| 87 | + innerOptions = [...refOptions]; |
88 | 88 | } |
89 | 89 |
|
90 | 90 | verifySelectAll(); |
|
96 | 96 | * @param {any} option |
97 | 97 | */ |
98 | 98 | function checkOption(e, option) { |
99 | | - const found = innerOptions.find(x => x.key == option.key); |
100 | | - const refFound = refOptions.find(x => x.key == option.key); |
| 99 | + innerOptions = innerOptions.map(x => { |
| 100 | + if (x.key == option.key) { |
| 101 | + x.checked = e == null ? !x.checked : e.target.checked; |
| 102 | + } |
| 103 | + return { ...x }; |
| 104 | + }); |
101 | 105 |
|
102 | | - if (found && refFound) { |
103 | | - found.checked = e.target.checked; |
104 | | - refFound.checked = e.target.checked; |
105 | | - changeDisplayText(); |
106 | | - sendEvent(); |
107 | | - } |
| 106 | + refOptions = refOptions.map(x => { |
| 107 | + if (x.key == option.key) { |
| 108 | + x.checked = e == null ? !x.checked : e.target.checked; |
| 109 | + } |
| 110 | + return { ...x }; |
| 111 | + }); |
| 112 | +
|
| 113 | + changeDisplayText(); |
| 114 | + sendEvent(); |
108 | 115 | } |
109 | 116 |
|
110 | 117 | /** @param {any} e */ |
111 | 118 | function checkSelectAll(e) { |
112 | | - selectAllChecked = e.target.checked; |
| 119 | + selectAllChecked = e == null ? !selectAllChecked : e.target.checked; |
113 | 120 | innerOptions = innerOptions.map(x => { |
114 | 121 | return { ...x, checked: selectAllChecked } |
115 | 122 | }); |
|
275 | 282 | </div> |
276 | 283 | {#if innerOptions.length > 0} |
277 | 284 | {#if selectAll} |
278 | | - <li class="option-item"> |
| 285 | + <!-- svelte-ignore a11y-click-events-have-key-events --> |
| 286 | + <!-- svelte-ignore a11y-no-noninteractive-element-interactions --> |
| 287 | + <li |
| 288 | + class="option-item clickable" |
| 289 | + on:click={() => checkSelectAll(null)} |
| 290 | + > |
279 | 291 | <div class="line-align-center select-box"> |
280 | 292 | <Input |
281 | 293 | type="checkbox" |
|
289 | 301 | </li> |
290 | 302 | {/if} |
291 | 303 | {#each innerOptions as option, idx (idx)} |
292 | | - <li class="option-item"> |
| 304 | + <!-- svelte-ignore a11y-click-events-have-key-events --> |
| 305 | + <!-- svelte-ignore a11y-no-noninteractive-element-interactions --> |
| 306 | + <li |
| 307 | + class="option-item clickable" |
| 308 | + on:click={() => checkOption(null, option)} |
| 309 | + > |
293 | 310 | <div class="line-align-center select-box"> |
294 | 311 | <Input |
295 | 312 | type="checkbox" |
|
0 commit comments