#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 11 years ago by
comment:2 Changed 11 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
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 11 years ago by
That may be the goal of the utility, but it is never the desired behavior in any application.
comment:4 Changed 11 years ago by
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 11 years ago by
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.
Issue reproduced and fix verified in:
Both on Windows7 64bit
Pull request #688: https://github.com/jquery/jquery-ui/pull/688