@douyinfe/semi-ui 2.38.3-alpha.2-patch-3006 → 2.38.3-alpha.2-patch-2254

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.
@@ -86650,7 +86650,7 @@ const treeSelect_constants_numbers = {};
86650
86650
  class TreeSelectFoundation extends foundation {
86651
86651
  constructor(adapter) {
86652
86652
  super(Object.assign({}, adapter));
86653
- this._registerClickOutsideHandler = e => {
86653
+ this._registerClickOutsideHandler = () => {
86654
86654
  this._adapter.registerClickOutsideHandler(e => {
86655
86655
  this.handlerTriggerBlur(e);
86656
86656
  this.close(e);
@@ -86666,11 +86666,13 @@ class TreeSelectFoundation extends foundation {
86666
86666
  const triggerSearch = searchPosition === treeSelect_constants_strings.SEARCH_POSITION_TRIGGER && filterTreeNode;
86667
86667
  const triggerSearchAutoFocus = searchAutoFocus && triggerSearch;
86668
86668
  this._setDropdownWidth();
86669
- const isOpen = (this.getProp('defaultOpen') || triggerSearchAutoFocus) && !this._isDisabled();
86669
+ const able = !this._isDisabled();
86670
+ const isOpen = (this.getProp('defaultOpen') || triggerSearchAutoFocus) && able;
86670
86671
  if (isOpen) {
86671
86672
  this.open();
86673
+ this._registerClickOutsideHandler();
86672
86674
  }
86673
- if (triggerSearchAutoFocus) {
86675
+ if (triggerSearchAutoFocus && able) {
86674
86676
  this.handleTriggerFocus(null);
86675
86677
  }
86676
86678
  }
@@ -86901,7 +86903,7 @@ class TreeSelectFoundation extends foundation {
86901
86903
  handleTriggerFocus(e) {
86902
86904
  this._adapter.updateIsFocus(true);
86903
86905
  this._notifyFocus(e);
86904
- this._registerClickOutsideHandler(e);
86906
+ this._registerClickOutsideHandler();
86905
86907
  }
86906
86908
  // Scenes that may trigger blur
86907
86909
  // 1、clickOutSide
@@ -86911,6 +86913,10 @@ class TreeSelectFoundation extends foundation {
86911
86913
  this._adapter.notifyBlur(e);
86912
86914
  }
86913
86915
  handlerTriggerBlur(e) {
86916
+ const isFocus = this.getState('isFocus');
86917
+ if (!isFocus) {
86918
+ return;
86919
+ }
86914
86920
  this._adapter.updateIsFocus(false);
86915
86921
  this._notifyBlur(e);
86916
86922
  this._adapter.unregisterClickOutsideHandler();
@@ -88412,6 +88418,7 @@ class TreeSelect extends BaseComponent {
88412
88418
  };
88413
88419
  const treeSelectAdapter = {
88414
88420
  registerClickOutsideHandler: cb => {
88421
+ this.adapter.unregisterClickOutsideHandler();
88415
88422
  const clickOutsideHandler = e => {
88416
88423
  const optionInstance = this.optionsRef && this.optionsRef.current;
88417
88424
  const triggerDom = this.triggerRef && this.triggerRef.current;
@@ -88426,6 +88433,9 @@ class TreeSelect extends BaseComponent {
88426
88433
  document.addEventListener('mousedown', clickOutsideHandler, false);
88427
88434
  },
88428
88435
  unregisterClickOutsideHandler: () => {
88436
+ if (!this.clickOutsideHandler) {
88437
+ return;
88438
+ }
88429
88439
  document.removeEventListener('mousedown', this.clickOutsideHandler, false);
88430
88440
  this.clickOutsideHandler = null;
88431
88441
  },