Skip to main content

Search and Top Navigation

#8425 closed bug (notabug)

Opened July 04, 2012 05:46PM UTC

Closed July 04, 2012 06:46PM UTC

Last modified July 04, 2012 08:03PM UTC

UI Position doesn't handle fixed elements correctly

Reported by: Jens Roland Owned by:
Priority: minor Milestone: 1.9.0
Component: ui.position Version: 1.8.21
Keywords: Cc:
Blocked by: Blocking:
Description

The Position utility script doesn't account for the target element being fixed to the viewport (position:fixed).

The source element (the one we are trying to position next to the target, e.g. a tooltip) needs to become fixed if the target is, in order to stay adjacent to it if the user subsequently scrolls down the page.

Demo: http://jsfiddle.net/3CBRa/9/

Proposed fix: On line 213, add:

    if (target.css('position')=='fixed') elem.css('position','fixed');

Demo with implemented fix: http://jsfiddle.net/gJpNT/1/

I will submit a pull request right away.

Attachments (0)
Change History (5)

Changed July 04, 2012 05:57PM UTC by Jens Roland comment:1

Issue reproduced and fix verified in:

  • Chrome 19.0.1084.56
  • Firefox 13.0.1

Both on Windows7 64bit

Pull request #688: https://github.com/jquery/jquery-ui/pull/688

Changed July 04, 2012 06:46PM UTC by scottgonzalez comment:2

resolution: → invalid
status: newclosed

This is not a bug. The position utility is purely for setting the position, not the type of positioning that the element uses. If you want the element to follow it, that's a separate decision from deciding that at a specific time two elements should be aligned in a specific way.

Changed July 04, 2012 07:20PM UTC by Jens Roland comment:3

That may be the goal of the utility, but it is never the desired behavior in any application.

Changed July 04, 2012 07:22PM UTC by scottgonzalez comment:4

That's actually not true. Besides, what you want is not solved by just setting position. What happens if the target element is repositioned later? What happens if the target element isn't fixed, but is contained in a scrollable parent? What happens if the element being positioned is contained in a scrollable parent? All of these cases are completely out of scope for this plugin.

Changed July 04, 2012 08:03PM UTC by Jens Roland comment:5

I'm not sure, but I believe those are covered as long as the positioned element is inserted after the target element. But I see yout point - I'll probably branch off into a separate project then, and make the changes there. Thanks for the fast reply.