Skip to content

Commit

Permalink
Remove onMount in ListFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
laurakwhit committed Nov 20, 2024
1 parent 69766cf commit b1bb5e0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
23 changes: 9 additions & 14 deletions src/lib/components/search-attribute-filter/list-filter.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { getContext, onMount } from 'svelte';
import { getContext } from 'svelte';
import Button from '$lib/holocene/button.svelte';
import ChipInput from '$lib/holocene/input/chip-input.svelte';
Expand All @@ -9,19 +9,14 @@
const { filter, handleSubmit } = getContext<FilterContext>(FILTER_CONTEXT);
let list: string[] = [];
onMount(() => {
const { value } = $filter;
const initialList =
value.length > 0
? value
.slice(1, -1)
.split(', ')
.map((v) => v.slice(1, -1))
: [];
list = initialList;
});
$: ({ value } = $filter);
$: list =
value.length > 0
? value
.slice(1, -1)
.split(', ')
.map((v) => v.slice(1, -1))
: [];
function onSubmit() {
$filter.conditional = 'IN';
Expand Down
4 changes: 2 additions & 2 deletions src/lib/holocene/input/chip-input.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
hintText: { name: 'Hint Text', control: 'text' },
disabled: { name: 'Disabled', control: 'boolean' },
required: { name: 'Required', control: 'boolean' },
external: { name: 'External Content', control: 'boolean' },
external: { name: 'External Chips', control: 'boolean' },
labelHidden: { name: 'Label Hidden', control: 'boolean' },
chips: { name: 'Chips', table: { disable: true } },
validator: { table: { disable: true } },
Expand All @@ -49,7 +49,7 @@

<Story name="Default" />

<Story name="External Content" args={{ external: true }} />
<Story name="External Chips" args={{ external: true }} />

<Story name="Disabled" args={{ disabled: true }} />

Expand Down

0 comments on commit b1bb5e0

Please sign in to comment.