Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#14962 closed bug (notabug)

Tooltips shown automatically when entering page with a hash URL, :not doesn't work in selector

Reported by: Przemek Pawlas Owned by:
Priority: minor Milestone: none
Component: ui.tooltip Version: 1.11.4
Keywords: Cc:
Blocked by: Blocking:

Description

I'm not sure whether it's a bug or I'm missing something, but:

jQuery: 1.11.3 and lower Affected browsers: latest Chrome, latest Firefox, latest IE (that's what I tested with, probably all are affected) OS: Windows 7 x64

How to reproduce:

  1. Add an anchor element with name and title.
  2. Add tooltips to document in $(document).ready (if you try to avoid the anchor with :not, it doesn't work).
  3. Open page with the #name in the URL.

It will show a tooltip for the anchor that can be closed when you click on it. Expected - it shouldn't be shown at all.

If you use $(window).load instead of $(document).ready, it works better - it's shown only when you switch browser tabs. :not still doesn't do anything though.

Code: http://jsbin.com/mecupu/edit?html,js Test: http://output.jsbin.com/mecupu#pid105

Same thing happens in 1.12 RC. If I choose to use the git version in JSbin, $(document).ready tooltips works like $(window).load and $(window).load tooltips don't work at all.

Change History (6)

comment:1 Changed 3 years ago by Scott González

Resolution: notabug
Status: newclosed

This is not a bug. By using the fragment identifier in the URL, you're placing focus on the anchor. Tooltips open on focus. Also, your selector for trying to exclude the anchor is wrong because you're selecting literally every element in the document other than the one anchor, which includes all the anchor's ancestors.

comment:2 Changed 3 years ago by Przemek Pawlas

Ok, thanks for info. Could you tell how can I prevent it in that case? Is there any way to add tooltips to everything but elements with one class? Or make the tooltip work only on hover, not focus?

comment:3 Changed 3 years ago by Przemek Pawlas

Never mind, it's as simple as $(document).tooltip().off('focusin focusout');

comment:4 Changed 3 years ago by Scott González

Is there any way to add tooltips to everything but elements with one class?

You should use the `items` options for that.

Or make the tooltip work only on hover, not focus?

PLEASE do not do this. You're breaking accessibility if you do.

comment:5 in reply to:  4 Changed 3 years ago by Przemek Pawlas

You should use the `items` options for that.

Ok, I see, thanks.

PLEASE do not do this. You're breaking accessibility if you do.

What exactly do you mean? If I don't want tooltips on focused inputs and links, what else could get broken? I guess tabindex and similar stuff, but it's definitely not a high priority feature for me.

comment:6 Changed 3 years ago by Scott González

There are users who don't, or can't, use pointing devices. Showing tooltips on focus is important for these users.

Note: See TracTickets for help on using tickets.