Skip to content

Commit

Permalink
clear button to type="button"
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-balfre committed May 14, 2023
1 parent 976bf3e commit afc8915
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/lib/Select.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@
{/if}
{#if showClear}
<button class="icon clear-select" on:pointerup|preventDefault|stopPropagation={handleClear}>
<button type="button" class="icon clear-select" on:click={handleClear}>
<slot name="clear-icon">
<ClearIcon />
</slot>
Expand Down
9 changes: 3 additions & 6 deletions test/src/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1458,8 +1458,7 @@ test('when multiple is true and items are selected then clear all should wipe al
}
});

const event = new PointerEvent('pointerup')
document.querySelector('.clear-select').dispatchEvent(event);
document.querySelector('.clear-select').click();
t.equal(select.value, undefined);

select.$destroy();
Expand Down Expand Up @@ -1790,8 +1789,7 @@ test('when value is cleared the clear event is fired', async (t) => {
clearEvent = true;
});

const event = new PointerEvent('pointerup')
document.querySelector('.clear-select').dispatchEvent(event);
document.querySelector('.clear-select').click();

t.ok(clearEvent);

Expand Down Expand Up @@ -1840,8 +1838,7 @@ test('when single item is cleared the clear event is fired with removed item', a
removedItem = event.detail;
});

const event = new PointerEvent('pointerup')
document.querySelector('.clear-select').dispatchEvent(event);
document.querySelector('.clear-select').click();
t.equal(JSON.stringify(removedItem), JSON.stringify(itemToRemove));

select.$destroy();
Expand Down

0 comments on commit afc8915

Please sign in to comment.