Skip to content

Commit 9ecd26e

Browse files
committed
Fix: Clear button causes crash in Singleselect
Refs: #8008
1 parent 6943f75 commit 9ecd26e

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

packages/components/src/components/single-select/shadow.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { tryToDispatchKoliBriEvent } from '../../utils/events';
2828
import { getRenderStates } from '../input/controller';
2929
import { InternalUnderlinedBadgeText } from '../span/InternalUnderlinedBadgeText';
3030
import { SingleSelectController } from './controller';
31+
import { EventDetail } from '../../schema/interfaces/EventDetail';
3132

3233
/**
3334
* @slot - The input field label.
@@ -93,13 +94,21 @@ export class KolSingleSelect implements SingleSelectAPI {
9394
if (this.state._disabled) {
9495
return;
9596
} else {
96-
const emptyValue = '';
97+
const emptyValue = null;
9798
this._focusedOptionIndex = -1;
9899
this._value = emptyValue;
99-
this._inputValue = emptyValue;
100+
this._inputValue = '';
100101
this._filteredOptions = [...this.state._options];
101-
this.controller.onFacade.onInput(new CustomEvent('input', { bubbles: true, detail: { name: this.state._name, value: emptyValue } }), true, emptyValue);
102-
this.controller.onFacade.onChange(new CustomEvent('change', { bubbles: true, detail: { name: this.state._name, value: emptyValue } }), emptyValue);
102+
103+
this.controller.onFacade.onInput(
104+
new CustomEvent<EventDetail>('input', { bubbles: true, detail: { name: this.state._name as string, value: emptyValue } }),
105+
true,
106+
{ value: emptyValue },
107+
);
108+
this.controller.onFacade.onChange(
109+
new CustomEvent<EventDetail>('change', { bubbles: true, detail: { name: this.state._name as string, value: emptyValue } }),
110+
{ value: emptyValue },
111+
);
103112
}
104113
}
105114

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import type { StencilUnknown } from '../types';
2+
3+
export interface EventDetail {
4+
name: string;
5+
value: StencilUnknown;
6+
}

0 commit comments

Comments
 (0)