Opened 17 years ago
Closed 17 years ago
#5067 closed (fixed)
Calendar and clock popups are wrongly positioned if within a scrollable div
Reported by: | Owned by: | Robert Coup | |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Keywords: | DateTimeShortcuts calendar clock admin scrolling position | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
The calendar and clock popups created through DateTimeShortcuts.js are positioned relative to cumulative offset (left and top) of all parent objects. This doesn't work if the firing up the popup is within a scrollable div. The popups get misaligned by the actual distances scrolled. This is very easily fixed by subtracting the scrolled distance from the objects' offsets whilst iterating through.
See attached patch of core.js.
Attachments (6)
Change History (13)
by , 17 years ago
Attachment: | patch.diff added |
---|
comment:1 by , 17 years ago
Owner: | changed from | to
---|
comment:2 by , 17 years ago
Please hold on for a while. The current patch does not work on simpler pages like the admin pages. Still working on a patch that works on all browsers - if that's actually possible.
by , 17 years ago
Attachment: | patch.3.diff added |
---|
Updated Patch, has now been tested on IE6/7, Firefox 2.0.0.6 and Safari 3.0.3 using the default admin view and a scrollable fixed positioned div (both scrolled and not scrolled)
by , 17 years ago
Attachment: | locationtest.html added |
---|
Demonstration of the problem, and the fix in action.
comment:3 by , 17 years ago
Triage Stage: | Unreviewed → Accepted |
---|
The attached locationtest.html demonstrates the problem. It contains a copy of the existing findXPos and findYPos, plus the fixed versions from the patch. However, I'm not too happy with the explicit user agent checking. Can anyone suggest a better approach here?
comment:4 by , 17 years ago
Owner: | changed from | to
---|---|
Patch needs improvement: | set |
Status: | new → assigned |
comment:5 by , 17 years ago
I'm having some difficulty with the reasoning here. It's an unfortunate fact that web browsers behave differently and hence it's not always possible to get everything working with one line of code. But leaving it broken for all browsers, doesn't seem like the best way to go. Practicality should rule over purity.
comment:6 by , 17 years ago
The new patch (4) is better and still reasonably simple. Tested in Safari3, IE6, IE7, FF2, Opera9. Opera was broken in patch 3.
There are a number of edge cases where it won't work, but without going to a full-blown framework like Dojo you won't get there. I've put in a slightly safer & faster version in the testcase html, but its probably not necessary.
Still known broken:
- R-to-L text direction in IE will put it backwards.
- If the node is an absolutely positioned child of a body with a margin set in Safari
comment:7 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
patch of core.js to cater for scrolling when calculating positions