Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#8425 closed bug (notabug)

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.

Change History (5)

comment:1 Changed 8 years ago by Jens Roland

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

comment:2 Changed 8 years ago by Scott González

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.

comment:3 Changed 8 years ago by Jens Roland

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

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

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.

comment:5 Changed 8 years ago by Jens Roland

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.

Note: See TracTickets for help on using tickets.