@douyinfe/semi-ui 2.38.0 → 2.38.2-alpha.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.
@@ -17854,9 +17854,14 @@ class AnchorFoundation extends foundation {
17854
17854
  */
17855
17855
  behavior: actions => {
17856
17856
  // We just need to scroll the innermost target container
17857
- const innermostAction = get_default()(actions, '0');
17858
- const el = get_default()(innermostAction, 'el');
17859
- const top = get_default()(innermostAction, 'top');
17857
+ const verticalScrollAction = actions.find(action => {
17858
+ const {
17859
+ el
17860
+ } = action;
17861
+ return el.scrollHeight > el.clientHeight;
17862
+ });
17863
+ const el = get_default()(verticalScrollAction, 'el');
17864
+ const top = get_default()(verticalScrollAction, 'top');
17860
17865
  if (el) {
17861
17866
  const offsetTop = top - targetOffset;
17862
17867
  if (el.scroll && canSmoothScroll) {
@@ -26676,9 +26681,10 @@ class AutoCompleteFoundation extends foundation {
26676
26681
  }
26677
26682
  }
26678
26683
  destroy() {
26679
- // this._adapter.unregisterClickOutsideHandler();
26684
+ this._adapter.unregisterClickOutsideHandler();
26680
26685
  // this.unBindKeyBoardEvent();
26681
26686
  }
26687
+
26682
26688
  _setDropdownWidth() {
26683
26689
  const {
26684
26690
  style,
@@ -26715,14 +26721,14 @@ class AutoCompleteFoundation extends foundation {
26715
26721
  this.isPanelOpen = true;
26716
26722
  this._adapter.toggleListVisible(true);
26717
26723
  this._setDropdownWidth();
26718
- // this._adapter.registerClickOutsideHandler(e => this.closeDropdown(e));
26724
+ this._adapter.registerClickOutsideHandler(e => this.closeDropdown(e));
26719
26725
  this._adapter.notifyDropdownVisibleChange(true);
26720
26726
  this._modifyFocusIndexOnPanelOpen();
26721
26727
  }
26722
26728
  closeDropdown(e) {
26723
26729
  this.isPanelOpen = false;
26724
26730
  this._adapter.toggleListVisible(false);
26725
- // this._adapter.unregisterClickOutsideHandler();
26731
+ this._adapter.unregisterClickOutsideHandler();
26726
26732
  this._adapter.notifyDropdownVisibleChange(false);
26727
26733
  // After closing the panel, you can still open the panel by pressing the enter key
26728
26734
  // this.unBindKeyBoardEvent();
@@ -28306,6 +28312,7 @@ var autoComplete = __webpack_require__("PyaV");
28306
28312
 
28307
28313
 
28308
28314
 
28315
+
28309
28316
  const autoComplete_prefixCls = autoComplete_constants_cssClasses.PREFIX;
28310
28317
  const autoComplete_sizeSet = autoComplete_constants_strings.SIZE;
28311
28318
  const autoComplete_positionSet = autoComplete_constants_strings.POSITION;
@@ -28430,6 +28437,24 @@ class AutoComplete extends BaseComponent {
28430
28437
  this.setState({
28431
28438
  rePosKey
28432
28439
  });
28440
+ },
28441
+ registerClickOutsideHandler: cb => {
28442
+ const clickOutsideHandler = e => {
28443
+ const optionInstance = this.optionsRef && this.optionsRef.current;
28444
+ const triggerDom = this.triggerRef && this.triggerRef.current;
28445
+ const optionsDom = external_root_ReactDOM_commonjs2_react_dom_commonjs_react_dom_amd_react_dom_default().findDOMNode(optionInstance);
28446
+ const target = e.target;
28447
+ if (optionsDom && (!optionsDom.contains(target) || !optionsDom.contains(target.parentNode)) && triggerDom && !triggerDom.contains(target)) {
28448
+ cb(e);
28449
+ }
28450
+ };
28451
+ this.clickOutsideHandler = clickOutsideHandler;
28452
+ document.addEventListener('mousedown', clickOutsideHandler, false);
28453
+ },
28454
+ unregisterClickOutsideHandler: () => {
28455
+ if (this.clickOutsideHandler) {
28456
+ document.removeEventListener('mousedown', this.clickOutsideHandler, false);
28457
+ }
28433
28458
  }
28434
28459
  });
28435
28460
  }