-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Fix hide sidebar tooltip on touchend events #28042
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix hide sidebar tooltip on touchend events #28042
Conversation
c5d828d to
6c846e9
Compare
6c846e9 to
3f196f7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes an issue where sidebar tooltips persist indefinitely on touch devices (primarily tablets) after tapping a sidebar item. The tooltip remains visible until the user taps elsewhere on the screen because touch devices don't trigger mouseleave events and the focused item doesn't lose focus automatically.
Key Changes
- Added
_touchendTimeoutproperty to track the touchend-triggered hide timeout - Added
@touchendevent handler toha-md-listelement that hides tooltips after a 1-second delay - Implemented
_listboxTouchend()method to handle the touchend event with a delayed tooltip hide
Comments suppressed due to low confidence (1)
src/components/ha-sidebar.ts:669
- The
_touchendTimeoutshould be cleared in_listboxScrollto prevent a delayed_hideTooltip()call after the user has scrolled. When scrolling occurs, the tooltip should hide immediately without waiting for the touchend timeout to complete.
Consider updating the method:
@eventOptions({
passive: true,
})
private _listboxScroll() {
// On keypresses on the listbox, we're going to ignore scroll events
// for 100ms so that if pressing down arrow scrolls the sidebar, the tooltip
// will not be hidden.
if (new Date().getTime() < this._recentKeydownActiveUntil) {
return;
}
if (this._touchendTimeout) {
clearTimeout(this._touchendTimeout);
this._touchendTimeout = undefined;
}
this._hideTooltip();
} @eventOptions({
passive: true,
})
private _listboxScroll() {
// On keypresses on the listbox, we're going to ignore scroll events
// for 100ms so that if pressing down arrow scrolls the sidebar, the tooltip
// will not be hidden.
if (new Date().getTime() < this._recentKeydownActiveUntil) {
return;
}
this._hideTooltip();
}
4abda97 to
197e3ca
Compare
197e3ca to
1de7192
Compare
* fix: hide sidebar tooltip on touchend events * Add a comment recommended by Copilot * Clear timeouts id in disconnectedCallback
Proposed change
The sidebar's tooltips do not disappear in touch devices (reported here and here). After tapping on an item the relative tooltip appears and it doesn't disappear until one taps on another part of the screen. This is due to the fact that tooltips appear on
focusinandmouseenterevents and are removed onfocusoutandmouseleaveevents. In desktop devices, this is not an issue because once one moves the mouse out of the item, the respective tooltip disappears. But in touch devices (mainly tablets because in mobile devices the sidebar gets hidden), the items get focus once tapped but they do not lose the focus until one taps in another part of the screen and there is nomouseleavein these devices.In this pull request this is fixed adding a
touchendevent to theha-md-listelement which executes the removal of the tooltip. The removal of the tooltip is done with a delay to allow its text to be read.Before
Record_2025-11-22-03-00-54_40deb401b9ffe8e1df2f1cc5ba480b12.2.mp4
After
Record_2025-11-22-02-55-59_40deb401b9ffe8e1df2f1cc5ba480b12.2.mp4
Type of change
Example configuration
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: