Skip to content

Commit

Permalink
minor fix for combobox
Browse files Browse the repository at this point in the history
  • Loading branch information
tborychowski committed Jan 14, 2024
1 parent 2852215 commit 6ec2109
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 108 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
Changelog
=========

## v9.4.3 *(2024-01-14)*
## v9.4.4, v9.4.3 *(2024-01-14)*
- More bugfixes, tests and some optimisations of the `Combobox` component.
- Fix to allow to clear the value of the `Combobox` by setting its value to `null` or `[]`.


## v9.4.2 *(2024-01-10)*
Expand Down
14 changes: 11 additions & 3 deletions docs-src/components/input/combobox/Combobox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<h4>Selected value: </h4>
<JsonBox value="{itemValue}" />

<Button on:click="{resetSingle}">Reset</Button>

<h3>Disabled</h3>
<Combobox disabled {items} bind:value="{itemValue}" />
Expand Down Expand Up @@ -65,7 +65,7 @@
bind:value="{multiselectSimpleValue}" />
<h4>Selected value: </h4>
<JsonBox value="{multiselectSimpleValue}" />

<Button on:click="{resetMulti}">Reset</Button>

<h3>Complex data</h3>
<Combobox
Expand All @@ -84,7 +84,7 @@


<script>
import { Combobox } from '../../../../src';
import { Combobox, Button } from '../../../../src';
import { API } from '../../../api-table';
import { CodeExample, JsonBox } from '../../../code-example';
Expand Down Expand Up @@ -212,4 +212,12 @@ function onChange (e) {
console.log({ value, oldValue });
}
function resetSingle () {
itemValue = null;
}
function resetMulti () {
multiselectSimpleValue = [];
}
</script>
3 changes: 2 additions & 1 deletion docs-src/pages/changelog.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<h1>Changelog</h1>
<h2>v9.4.3 <em>(2024-01-14)</em></h2>
<h2>v9.4.4, v9.4.3 <em>(2024-01-14)</em></h2>
<ul>
<li>More bugfixes, tests and some optimisations of the <code>Combobox</code> component.</li>
<li>Fix to allow to clear the value of the <code>Combobox</code> by setting its value to <code>null</code> or <code>[]</code>.</li>
</ul>
<h2>v9.4.2 <em>(2024-01-10)</em></h2>
<ul>
Expand Down
200 changes: 100 additions & 100 deletions docs/docs.js

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions src/input/combobox/Combobox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,6 @@ function selectMultiselect (item) {
function setInitialValue () {
if (!filteredData || !filteredData.length) return;
if (!value || (Array.isArray(value) && !value.length)) return;
if (multiselect) {
if (!Array.isArray(value)) value = [value];
Expand All @@ -337,7 +336,7 @@ function setInitialValue () {
else inputValue = getInputValue(selectedItems, multiselect);
}
else {
const itemId = value.id || value.name || value;
const itemId = value?.id || value?.name || value;
if (itemId) {
const item = filteredData.find(i => (i.id || i.name || i) === itemId);
if (item) {
Expand Down
2 changes: 1 addition & 1 deletion src/input/combobox/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export function alignDropdown (listElement, inputElement, e) {


function hasSingleValueChanged (oldV, newV) {
return (oldV.id || oldV.name || oldV) !== (newV.id || newV.name || newV);
return (oldV?.id || oldV?.name || oldV) !== (newV?.id || newV?.name || newV);
}


Expand Down

0 comments on commit 6ec2109

Please sign in to comment.