-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: improve mobile tooltip behavior
See primefaces/primevue#3576 + there's a patch for left side overflow
- Loading branch information
1 parent
2d87044
commit 8f701c8
Showing
3 changed files
with
58 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,7 +61,8 @@ | |
}, | ||
"pnpm": { | ||
"patchedDependencies": { | ||
"@primevue/[email protected]": "patches/@[email protected]" | ||
"@primevue/[email protected]": "patches/@[email protected]", | ||
"[email protected]": "patches/[email protected]" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
diff --git a/tooltip/index.mjs b/tooltip/index.mjs | ||
index b5f50d9605456e01ce14fdeadd80054c421d67b2..182f9cd6f0c5d142f21a78178db41748e428a103 100644 | ||
--- a/tooltip/index.mjs | ||
+++ b/tooltip/index.mjs | ||
@@ -110,9 +110,11 @@ var Tooltip = BaseTooltip.extend('tooltip', { | ||
el.$_mouseenterevent = function (event) { | ||
return _this.onMouseEnter(event, options); | ||
}; | ||
+ el.$_tleave = this.onMouseLeave.bind(this); | ||
+ el.$_tclick = (e) => this.onClick(e); | ||
el.addEventListener('mouseenter', el.$_mouseenterevent); | ||
- el.addEventListener('mouseleave', this.onMouseLeave.bind(this)); | ||
- el.addEventListener('click', this.onClick.bind(this)); | ||
+ el.addEventListener('mouseleave', el.$_tleave); | ||
+ el.addEventListener('click', el.$_tclick); | ||
} | ||
el.addEventListener('keydown', this.onKeydown.bind(this)); | ||
}, | ||
@@ -125,8 +127,8 @@ var Tooltip = BaseTooltip.extend('tooltip', { | ||
} else { | ||
el.removeEventListener('mouseenter', el.$_mouseenterevent); | ||
el.$_mouseenterevent = null; | ||
- el.removeEventListener('mouseleave', this.onMouseLeave.bind(this)); | ||
- el.removeEventListener('click', this.onClick.bind(this)); | ||
+ el.removeEventListener('mouseleave', el.$_tleave); | ||
+ el.removeEventListener('click', el.$_tclick); | ||
} | ||
el.removeEventListener('keydown', this.onKeydown.bind(this)); | ||
}, | ||
@@ -173,7 +175,7 @@ var Tooltip = BaseTooltip.extend('tooltip', { | ||
onClick: function onClick(event) { | ||
var el = event.currentTarget; | ||
var hideDelay = el.$_ptooltipHideDelay; | ||
- this.hide(el, hideDelay); | ||
+ this.getTooltipElement(el) && this.hide(el, hideDelay); | ||
}, | ||
onKeydown: function onKeydown(event) { | ||
var el = event.currentTarget; | ||
@@ -355,7 +357,7 @@ var Tooltip = BaseTooltip.extend('tooltip', { | ||
this.preAlign(el, 'top'); | ||
var tooltipElement = this.getTooltipElement(el); | ||
var hostOffset = this.getHostOffset(el); | ||
- var left = hostOffset.left + (getOuterWidth(el) - getOuterWidth(tooltipElement)) / 2; | ||
+ var left = Math.max(hostOffset.left + (getOuterWidth(el) - getOuterWidth(tooltipElement)) / 2, 0); | ||
var top = hostOffset.top - getOuterHeight(tooltipElement); | ||
tooltipElement.style.left = left + 'px'; | ||
tooltipElement.style.top = top + 'px'; | ||
diff --git a/tooltip/index.mjs.map b/tooltip/index.mjs.map | ||
deleted file mode 100644 | ||
index ccbc21d64ef2acb77675ba64786fa8385e23333b..0000000000000000000000000000000000000000 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.