@douyinfe/semi-ui 2.38.0 → 2.38.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/umd/semi-ui.js
CHANGED
|
@@ -26676,9 +26676,10 @@ class AutoCompleteFoundation extends foundation {
|
|
|
26676
26676
|
}
|
|
26677
26677
|
}
|
|
26678
26678
|
destroy() {
|
|
26679
|
-
|
|
26679
|
+
this._adapter.unregisterClickOutsideHandler();
|
|
26680
26680
|
// this.unBindKeyBoardEvent();
|
|
26681
26681
|
}
|
|
26682
|
+
|
|
26682
26683
|
_setDropdownWidth() {
|
|
26683
26684
|
const {
|
|
26684
26685
|
style,
|
|
@@ -26715,14 +26716,14 @@ class AutoCompleteFoundation extends foundation {
|
|
|
26715
26716
|
this.isPanelOpen = true;
|
|
26716
26717
|
this._adapter.toggleListVisible(true);
|
|
26717
26718
|
this._setDropdownWidth();
|
|
26718
|
-
|
|
26719
|
+
this._adapter.registerClickOutsideHandler(e => this.closeDropdown(e));
|
|
26719
26720
|
this._adapter.notifyDropdownVisibleChange(true);
|
|
26720
26721
|
this._modifyFocusIndexOnPanelOpen();
|
|
26721
26722
|
}
|
|
26722
26723
|
closeDropdown(e) {
|
|
26723
26724
|
this.isPanelOpen = false;
|
|
26724
26725
|
this._adapter.toggleListVisible(false);
|
|
26725
|
-
|
|
26726
|
+
this._adapter.unregisterClickOutsideHandler();
|
|
26726
26727
|
this._adapter.notifyDropdownVisibleChange(false);
|
|
26727
26728
|
// After closing the panel, you can still open the panel by pressing the enter key
|
|
26728
26729
|
// this.unBindKeyBoardEvent();
|
|
@@ -28306,6 +28307,7 @@ var autoComplete = __webpack_require__("PyaV");
|
|
|
28306
28307
|
|
|
28307
28308
|
|
|
28308
28309
|
|
|
28310
|
+
|
|
28309
28311
|
const autoComplete_prefixCls = autoComplete_constants_cssClasses.PREFIX;
|
|
28310
28312
|
const autoComplete_sizeSet = autoComplete_constants_strings.SIZE;
|
|
28311
28313
|
const autoComplete_positionSet = autoComplete_constants_strings.POSITION;
|
|
@@ -28430,6 +28432,24 @@ class AutoComplete extends BaseComponent {
|
|
|
28430
28432
|
this.setState({
|
|
28431
28433
|
rePosKey
|
|
28432
28434
|
});
|
|
28435
|
+
},
|
|
28436
|
+
registerClickOutsideHandler: cb => {
|
|
28437
|
+
const clickOutsideHandler = e => {
|
|
28438
|
+
const optionInstance = this.optionsRef && this.optionsRef.current;
|
|
28439
|
+
const triggerDom = this.triggerRef && this.triggerRef.current;
|
|
28440
|
+
const optionsDom = external_root_ReactDOM_commonjs2_react_dom_commonjs_react_dom_amd_react_dom_default().findDOMNode(optionInstance);
|
|
28441
|
+
const target = e.target;
|
|
28442
|
+
if (optionsDom && (!optionsDom.contains(target) || !optionsDom.contains(target.parentNode)) && triggerDom && !triggerDom.contains(target)) {
|
|
28443
|
+
cb(e);
|
|
28444
|
+
}
|
|
28445
|
+
};
|
|
28446
|
+
this.clickOutsideHandler = clickOutsideHandler;
|
|
28447
|
+
document.addEventListener('mousedown', clickOutsideHandler, false);
|
|
28448
|
+
},
|
|
28449
|
+
unregisterClickOutsideHandler: () => {
|
|
28450
|
+
if (this.clickOutsideHandler) {
|
|
28451
|
+
document.removeEventListener('mousedown', this.clickOutsideHandler, false);
|
|
28452
|
+
}
|
|
28433
28453
|
}
|
|
28434
28454
|
});
|
|
28435
28455
|
}
|