Skip to content

Conversation

@elchininet
Copy link
Contributor

@elchininet elchininet commented Nov 22, 2025

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 focusin and mouseenter events and are removed on focusout and mouseleave events. 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 no mouseleave in these devices.

In this pull request this is fixed adding a touchend event to the ha-md-list element 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

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example configuration

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue or discussion:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

@elchininet elchininet force-pushed the fix_persistent_sidebar_tooltips branch from c5d828d to 6c846e9 Compare November 22, 2025 14:10
@frenck frenck changed the title fix: hide sidebar tooltip on touchend events Fix hide sidebar tooltip on touchend events Nov 22, 2025
@elchininet elchininet force-pushed the fix_persistent_sidebar_tooltips branch from 6c846e9 to 3f196f7 Compare November 23, 2025 14:07
@frenck frenck requested a review from Copilot November 23, 2025 14:08
Copilot finished reviewing on behalf of frenck November 23, 2025 14:12
Copy link
Contributor

Copilot AI left a 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 _touchendTimeout property to track the touchend-triggered hide timeout
  • Added @touchend event handler to ha-md-list element 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 _touchendTimeout should be cleared in _listboxScroll to 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();
  }

@elchininet elchininet force-pushed the fix_persistent_sidebar_tooltips branch 3 times, most recently from 4abda97 to 197e3ca Compare November 26, 2025 17:52
@elchininet elchininet force-pushed the fix_persistent_sidebar_tooltips branch from 197e3ca to 1de7192 Compare November 26, 2025 17:53
@MindFreeze MindFreeze added this to the 2025.12 milestone Nov 27, 2025
@MindFreeze MindFreeze merged commit e80a855 into home-assistant:dev Nov 27, 2025
15 checks passed
@elchininet elchininet deleted the fix_persistent_sidebar_tooltips branch November 27, 2025 08:27
bramkragten pushed a commit that referenced this pull request Nov 27, 2025
* fix: hide sidebar tooltip on touchend events

* Add a comment recommended by Copilot

* Clear timeouts id in disconnectedCallback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants