|
@@ -32,7 +32,7 @@ export interface SelectAdapter<P = Record<string, any>, S = Record<string, any>>
|
|
|
notifyClear(): void;
|
|
|
updateInputValue(inputValue: string): void;
|
|
|
focusInput(): void;
|
|
|
- notifySearch(inputValue: string): void;
|
|
|
+ notifySearch(inputValue: string, event?: any): void;
|
|
|
registerKeyDown(handler: () => void): void;
|
|
|
unregisterKeyDown(): void;
|
|
|
notifyChange(value: string | BasicOptionProps | (string | BasicOptionProps)[]): void;
|
|
@@ -396,7 +396,7 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
|
|
|
|
|
|
this._adapter.once('popoverClose', () => {
|
|
|
if (isFilterable) {
|
|
|
- this.clearInput();
|
|
|
+ this.clearInput(e);
|
|
|
}
|
|
|
if (closeCb) {
|
|
|
closeCb();
|
|
@@ -467,7 +467,7 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
|
|
|
this._notifyChange(selections);
|
|
|
if (this._isFilterable()) {
|
|
|
if (autoClearSearchValue) {
|
|
|
- this.clearInput();
|
|
|
+ this.clearInput(event);
|
|
|
}
|
|
|
this.focusInput();
|
|
|
}
|
|
@@ -482,7 +482,7 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
|
|
|
if (this._isFilterable()) {
|
|
|
// When filter active,if autoClearSearchValue is true,reset input after select
|
|
|
if (autoClearSearchValue) {
|
|
|
- this.clearInput();
|
|
|
+ this.clearInput(event);
|
|
|
// At the same time, the filtering of options is also cleared, in order to show all candidates
|
|
|
const sugInput = '';
|
|
|
options = this._filterOption(options, sugInput);
|
|
@@ -550,12 +550,14 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- clearInput() {
|
|
|
+
|
|
|
+ // The reason why event input is optional is that clearInput may be manually called by the user through ref
|
|
|
+ clearInput(event?: any) {
|
|
|
const { inputValue } = this.getStates();
|
|
|
// only when input is not null, select should notifySearch and updateOptions
|
|
|
if (inputValue !== ''){
|
|
|
this._adapter.updateInputValue('');
|
|
|
- this._adapter.notifySearch('');
|
|
|
+ this._adapter.notifySearch('', event);
|
|
|
// reset options filter
|
|
|
const { options } = this.getStates();
|
|
|
const { remote } = this.getProps();
|
|
@@ -573,7 +575,7 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
|
|
|
this._adapter.setIsFocusInContainer(false);
|
|
|
}
|
|
|
|
|
|
- handleInputChange(sugInput: string) {
|
|
|
+ handleInputChange(sugInput: string, event: any) {
|
|
|
// Input is a controlled component, so the value needs to be updated
|
|
|
this._adapter.updateInputValue(sugInput);
|
|
|
const { options, isOpen } = this.getStates();
|
|
@@ -589,7 +591,7 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
|
|
|
optionsAfterFilter = this._createOptionByInput(allowCreate, optionsAfterFilter, sugInput);
|
|
|
|
|
|
this._adapter.updateOptions(optionsAfterFilter);
|
|
|
- this._adapter.notifySearch(sugInput);
|
|
|
+ this._adapter.notifySearch(sugInput, event);
|
|
|
// In multi-select mode, the drop-down box is repositioned each time you enter, because it may cause a line break as the input changes
|
|
|
if (this._isMultiple()) {
|
|
|
this._adapter.rePositionDropdown();
|
|
@@ -809,7 +811,7 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
|
|
|
}
|
|
|
} else {
|
|
|
// there are no focusable elements inside the container, tab to next element and trigger blur
|
|
|
- this.close();
|
|
|
+ this.close(event);
|
|
|
this._notifyBlur(event);
|
|
|
}
|
|
|
} else {
|
|
@@ -829,7 +831,7 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
|
|
|
} else if (activeElement === focusableElements[focusableElements.length - 1]) {
|
|
|
// focus in the last element in container, focus back to trigger and close panel
|
|
|
this._focusTrigger();
|
|
|
- this.close();
|
|
|
+ this.close(event);
|
|
|
handlePrevent(event);
|
|
|
}
|
|
|
}
|
|
@@ -840,7 +842,7 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
|
|
|
|
|
|
if (!isFocusInContainer) {
|
|
|
// focus in trigger, close the panel, shift tab to previe element and trigger blur
|
|
|
- this.close();
|
|
|
+ this.close(event);
|
|
|
this._notifyBlur(event);
|
|
|
} else if (activeElement === focusableElements[0]) {
|
|
|
// focus in the first element in container, focus back to trigger
|
|
@@ -870,7 +872,7 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
|
|
|
this.onSelect(selectedOption, focusIndex, event);
|
|
|
}
|
|
|
} else {
|
|
|
- this.close();
|
|
|
+ this.close(event);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1018,7 +1020,7 @@ export default class SelectFoundation extends BaseFoundation<SelectAdapter> {
|
|
|
handleClearClick(e: MouseEvent) {
|
|
|
const { filter } = this.getProps();
|
|
|
if (filter) {
|
|
|
- this.clearInput();
|
|
|
+ this.clearInput(e);
|
|
|
}
|
|
|
this.clearSelected();
|
|
|
// prevent this click open dropdown
|