Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/ui/src/combobox.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ function handleRoot(el, Alpine) {
// if a user passed the "name" prop...
this.__inputName && renderHiddenInputs(Alpine, this.$el, this.__inputName, this.__value)
})

Alpine.effect(() => ! this.__isMultiple && this.__resetInput())
})
},
__startTyping() {
Expand Down
10 changes: 10 additions & 0 deletions tests/cypress/integration/plugins/ui/combobox.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ test('it works with x-model',

<article x-text="selected?.name"></article>
</div>

<a href="#" x-on:click.prevent="selected = { id: 7, name: 'Caroline Schultz' }">Set selected via code</a>
</div>
`],
({ get }) => {
Expand Down Expand Up @@ -95,6 +97,9 @@ test('it works with x-model',
get('ul').should(notBeVisible())
get('input').should(haveValue('Wade Cooper'))
get('article').should(haveText('Wade Cooper'))
get('a').click()
get('input').should(haveValue('Caroline Schultz'))
get('article').should(haveText('Caroline Schultz'))
},
)

Expand Down Expand Up @@ -1209,6 +1214,7 @@ test('input reset',
</div>

<article>lorem ipsum</article>
<a x-on:click="selected = null">Clear</a>
</div>
`],
({ get }) => {
Expand Down Expand Up @@ -1265,6 +1271,10 @@ test('input reset',
get('input').type('w')
get('article').click()
get('input').should(haveValue('Arlene Mccoy'))

// Test correct state after clearing selected via code
get('a').click()
get('input').should(haveValue(''))
},
)

Expand Down