Skip to content

Commit

Permalink
Merge pull request #2309 from DouyinFE/fix_tooltip_mouseLeave_test
Browse files Browse the repository at this point in the history
fix: fix dropdown test
  • Loading branch information
DaiQiangReal authored Jun 21, 2024
2 parents dc543a1 + 128271d commit 170393b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
23 changes: 13 additions & 10 deletions packages/semi-foundation/tooltip/foundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,16 +313,7 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
show = () => {
const content = this.getProp('content');
const trigger = this.getProp('trigger');
if (trigger==="hover") {
const checkTriggerIsHover = () => {
const triggerDOM = this._adapter.getTriggerDOM();
if (trigger && !triggerDOM.matches(":hover")) {
this.hide();
}
this._adapter.off("portalInserted", checkTriggerIsHover);
};
this._adapter.on('portalInserted', checkTriggerIsHover);
}

const clickTriggerToHide = this.getProp('clickTriggerToHide');
const { visible, displayNone } = this.getStates();
if (displayNone) {
Expand All @@ -343,6 +334,18 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
this.calcPosition();
});

if (trigger==="hover") {
const checkTriggerIsHover = () => {
const triggerDOM = this._adapter.getTriggerDOM();
if (trigger && !triggerDOM.matches(":hover")) {
this.hide();
}
this._adapter.off("portalInserted", checkTriggerIsHover);
};
this._adapter.on('portalInserted', checkTriggerIsHover);
}


this._adapter.on('positionUpdated', () => {
this._togglePortalVisible(true);
});
Expand Down
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1618,6 +1618,13 @@
dependencies:
classnames "^2.2.6"

"@douyinfe/semi-icons@^2.0.0":
version "2.60.1"
resolved "https://registry.yarnpkg.com/@douyinfe/semi-icons/-/semi-icons-2.60.1.tgz#944de131585d4747f831cf4864ceb0d41d7d34c9"
integrity sha512-f6DxiYKUJaTaNnMFFIweQlKjTt5+m6SGZb09Z/2b9wtfqdulXTYMrmXXeQOzfLvTE4QFZb0CfR9DsCfiH6oyxQ==
dependencies:
classnames "^2.2.6"

"@douyinfe/[email protected]":
version "2.33.1"
resolved "https://registry.npmjs.org/@douyinfe/semi-illustrations/-/semi-illustrations-2.33.1.tgz#530ab851f4dc32a52221c4067c778c800b9b55d7"
Expand Down Expand Up @@ -11746,6 +11753,11 @@ eslint-plugin-react@^7.20.6, eslint-plugin-react@^7.24.0:
semver "^6.3.0"
string.prototype.matchall "^4.0.8"

eslint-plugin-semi-design@^2.33.0:
version "2.60.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-semi-design/-/eslint-plugin-semi-design-2.60.1.tgz#f93c328835ba7379dd55e264852d6e67bcde20d0"
integrity sha512-7rUY4P7gUkhU7q/xdjMa+yrFPmO1y5yEUG1v+7MPfe4sP6uo8qtf96VrIhCN+OAeHvN6jlgEIpuoRBt4d/gJDA==

eslint-rule-composer@^0.3.0:
version "0.3.0"
resolved "https://registry.npmjs.org/eslint-rule-composer/-/eslint-rule-composer-0.3.0.tgz#79320c927b0c5c0d3d3d2b76c8b4a488f25bbaf9"
Expand Down

0 comments on commit 170393b

Please sign in to comment.