Skip to content

Commit

Permalink
fix: value binding is missing on search bar
Browse files Browse the repository at this point in the history
  • Loading branch information
paring-chan committed Sep 29, 2024
1 parent b63a76f commit 1df4e15
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/lib/components/search/SearchBar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
placeholder?: TranslationKey
}
const { value = $bindable(''), placeholder }: Props = $props()
let { value = $bindable(''), placeholder }: Props = $props()
const ctx = getGlobalContext()
Expand All @@ -20,7 +20,12 @@
<div class="icon">
<Icon alt="icon" size={24} icon="search" />
</div>
<input type="text" class="input" placeholder={placeholder ? $translatedPlaceholder : ''} />
<input
bind:value
type="text"
class="input"
placeholder={placeholder ? $translatedPlaceholder : ''}
/>
</div>

<style lang="scss">
Expand Down
8 changes: 7 additions & 1 deletion src/stories/search/SearchBar.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
})
</script>

<script lang="ts">
let query = $state('')
</script>

<Story name="Example">
<SearchBar placeholder="custom:Wow this is placeholder" />
<SearchBar bind:value={query} placeholder="custom:Wow this is placeholder" />

<div>{query}</div>
</Story>

0 comments on commit 1df4e15

Please sign in to comment.