I discovered this issue while writing a small concept patch for #447816: WCAG violation: Relying on a color by itself to indicate a field validation error.
When you create an anchor link to an element, the browser will jump down so that the linked element is at the top of the window. Unfortunately, the toolbar will float over the linked item.
This is a problem, because this prevents valid and useful HTML from being used.
To test:
- Apply the patch from comment #12 in the issue linked above.
- Go to any form with required fields, such as the Site Information page.
- Submit the form with required field blank.
- Click the link in the generated error message.
Note that this won't work, of course, if the entire page fits on your monitor. If necessary, make your browser window narrower and shorter until there is a fair amount of extra vertical scroll room available.
Comment | File | Size | Author |
---|---|---|---|
#51 | anchor.png | 46.25 KB | zeta ζ |
#51 | edit-title.png | 18.88 KB | zeta ζ |
#51 | toolbar-546126.patch | 1.13 KB | zeta ζ |
#50 | toolbaranchor_0_1.patch | 2.12 KB | mgifford |
#41 | toolbaranchor.patch | 2.94 KB | casey |
Comments
Comment #1
webchickHere's a screenshot showing this in action; "Title" was clicked.
We obviously can't ship Drupal 7 with this not working, so marking critical.
Comment #2
mgiffordI do like how this works, but there are some problems with it for sure. I've added some other screenshots of this here http://drupal.org/node/447816#comment-1980664
Agreed that it's critical. Will just be causing confusion
Comment #3
bowersox CreditAttribution: bowersox commentedThanks for filing this issue. There are other places in the admin interface where anchors are used--I'll try to post examples here. One solution might be a Javascript enhancement that would turn anchors into Javascript that would scrollTo() with an appropriate fudge factor for the Seven toolbar.
Comment #4
Owen Barton CreditAttribution: Owen Barton commentedI agree with #3 that this should be a fix that lives with the seven toolbar JS, so that all anchors work as expected.
Comment #5
c960657 CreditAttribution: c960657 commentedSee the related issue, #567754: Wrong anchor adjustment in tableheader.js. The patch there fixes this for anchors inside a table with a sticky header (though a general solution would of course be better).
Comment #6
sunCool. My drupal.org unleashed user style has the same problem. I hope we find a neat CSS-only solution here. ;)
(And, btw, admin_menu doesn't have this issue, because it doesn't consume 15-20% of the visible viewport.)
Comment #7
bleen CreditAttribution: bleen commented@sun ... I would love to see a css-only solution here as well but I've been wracking my brain and the way I see it there are only a few options to make this happn w/o js:
if you have some other ideas I'm happy to do any of the heavy lifting to get them working but I'm stuck on his one ... I think it has to be a js solution ... Thoughts?
Comment #8
c960657 CreditAttribution: c960657 commentedmisc/jquery.ba-bbq.js implements adds cross-browser support for the window.onhashchange event. Upon this event we could increment the current scroll position by 30 pixels.
Comment #9
Owen Barton CreditAttribution: Owen Barton commentedAfter a little playing around, it seems like we might be able to add a use negative margins to pull anchor tags up by N pixels. We would need to add an class to these tags, since obviously we don't want this to apply to regular links - i.e.:
And then CSS (inheriting off a body class indicating if the toolbar is present) along the lines of:
Obviously the CSS would need to live in the theme, since different admin themes may have different sized toolbars. Of course, I haven't tested this in IE or Safari - does anyone have time to try that out and see if this is a viable approach?
Comment #10
sunThat sounds quite interesting, but unfortunately, limiting this to anchor tags doesn't work.
...is a valid jump target as well.
You can jump to this #target, if you want to try.
Comment #11
sunerrrrrrr. This is _really_ interesting. Played a bit with that. 8)
Try this in action. (Don't try this at home. ;)
.
errr. Undo this.
...
Comment #12
Owen Barton CreditAttribution: Owen Barton commentedGood point that you can use id with other tags. I think it is going to be pretty impossible to come up with a pure CSS negative-margin that works properly with h tags, because those will normally have theme styles that will clobber whatever we add. Perhaps what we could do is write a little JS behaviour that:
(a) finds *[id] attributes (i.e. on any tag)
(b) removes the original id (might be unnecessary, but I think duplicate IDs aren't allowed)
(c) adds an anchor tag with the same id directly in front, and adds a style or class that uses negative margins to pull it up as needed
Comment #13
bowersox CreditAttribution: bowersox commented@Owen, interesting idea. Removing the original ID might break contrib code, such as code that manipulates the page by ID in jQuery or using
getElementById().value='new'
. So as a slight variation of your proposal, we could instead keep the original ID in place, but add a new id in front (eg, 'origid-anchor-correct'). Then we would find all the href attributes and modify their targets from #origid to #origid-anchor-correct.Note: This variation would only work for 'internal links' that come from within the same page, not for anchors that appear in links from other pages or other websites.
Comment #14
sunnah, a JS-based solution would of course calculate the real offset in the viewport and move the document accordingly. Altering the DOM would break literally every other JS and CSS on the page.
Comment #15
eigentor CreditAttribution: eigentor commentedUpdate: the behavior has changed when jumping to the permissions page from the Modules page via the "permissions" operation: now it does not seem to accept any anchors and always jumps to the top of the permissions page.
Comment #16
bleen CreditAttribution: bleen commented@eigentor: this is issue is not specific to any one anchor link. In general, if i have a page with
<div id="jumpto">...</div>
and elsewhere on the page I have<a href="#jumpto">...</a>
then the Toolbar will interfere.Comment #17
casey CreditAttribution: casey commentedsubscribing
Comment #18
bleen CreditAttribution: bleen commentedI agree that a CSS-only solution would be preferable, but I think if there was one we would have uncovered it by now ... this solves the issue via javascript.
Review away
Comment #19
bleen CreditAttribution: bleen commentedFixed a tiny whitespace problem ... otherwise the patch is unchanged from #18
Comment #20
sunSingle quotes.
1) Why both body and html? Either one is superfluous or this needs an inline comment.
2) The jQuery selector is missing the context to search in.
Powered by Dreditor.
Comment #21
bleen CreditAttribution: bleen commented@sun:
Comment #22
casey CreditAttribution: casey commentedI would use $(window) or $(document.body) as it's faster.
Comment #23
sunDrupal behaviors get a "context" variable passed to them, which can be a window, document, or an arbitrary DOM element. This JS needs to account for that context, because we don't want to jump around in IFRAMEs, f.e. WYSIWYG editors on the page.
Additionally, this JS needs to account for the fact that Drupal behaviors can be attached multiple times at arbitrary times. Doesn't look this is covered already.
Comment #24
bleen CreditAttribution: bleen commented@casey: done
@sun: Still getting used to jquery in Drupal. I think all I needed to do was add that context var, yes? As for preventing the behavior from being attached multiple times, I'm not sure the way I'm going about it is the optimal solution, but it works. Basically I'm just doing an unbind before I bind the function. Thoughts?
Comment #25
casey CreditAttribution: casey commented- Improved comments
- Really no need to use context on window; Drupal behaviors are always applied to same window.
- No need to unbind when using a named function; it won't get bound twice
- Added a check to make sure anchor does actually exist
Comment #26
casey CreditAttribution: casey commentedWow this is going to collide with overlay. Bug in overlay. I'll post a issue for that bug. That one should go in first.
Comment #27
aspilicious CreditAttribution: aspilicious commentedDon't test latest patch...
SERIOUSLY DON'T :)
Comment #28
aspilicious CreditAttribution: aspilicious commentedOK UPDATE:
#25 is working now if you apply #684474: Overlay is re-applying behaviors first
Comment #29
casey CreditAttribution: casey commentedYes the other issue is critical and should go in first.
- Added namespaced event handler and trigger only that handler.
Comment #31
aspilicious CreditAttribution: aspilicious commentedTested in IE, ff and webkit. Works fine, if you apply other patch first offcourse.
In IE I discovered some realy realy bad issues but they are not related with this patch (I tested it on a fresh install).
Going to open topics for them.
Comment #32
aspilicious CreditAttribution: aspilicious commentedOOOPS, it is related.
In IE compatibilty mode or IE6, this patch makes a page scroll down to the end see screenshot.
Comment #33
casey CreditAttribution: casey commented#32 is not related to this issue. Please open a new issue for that.
// Edit: #32 is caused by jquery-ba-bbq.js: http://benalman.com/projects/jquery-bbq-plugin/#comment-152
Comment #34
webchickTagging.
Comment #35
aspilicious CreditAttribution: aspilicious commentedBut i have two installs, one with the patches one without...
Something must cause this....
Comment #36
webchickRe-tagging. ;)
Comment #37
sunSorry, but this is plain wrong. Drupal behaviors are initially applied on the current main window only, but all scripts are free to re-apply them at any point to the same window, to specific DOM elements on the page, or an embedded window, such as an iframe. Scripts are not only free to do so, they are actually doing this all over the time, if coded correctly.
I'll also follow-up on #684474: Overlay is re-applying behaviors
Comment #38
casey CreditAttribution: casey commentedAnyway, does $(window, context) actually work? I didn't test it, but I don't think so...
Comment #39
casey CreditAttribution: casey commentedApplying behaviors from one window to another (e.g. from parent window to an embedded iframe) fails currently. We could make it work by passing the context document/window.
Behaviors can than use the extra arguments when necessary.
But I am not sure why we want this to be possible.
Comment #40
sun.core CreditAttribution: sun.core commentedNot critical. Please read and understand Priority levels of Issues, thanks.
Please remove.
Wrong indentation.
Why isn't this using jqBBQ API functions? Or is this not covered?
Powered by Dreditor.
Comment #41
casey CreditAttribution: casey commentedReroll
Also fixed a bug in tableheader.js (I tested this issue on /admin/modules#edit-modules-views)
Comment #42
casey CreditAttribution: casey commented#787940: Generic approach for position:fixed elements like Toolbar, tableHeader landed. Now we can handle all displaced elements like the toolbar at once. We have however also to deal with other scripts that might want to adjust scrollTop (like tableheader.js: #567754: Wrong anchor adjustment in tableheader.js).
KipHaas7 and me worked on a cleanup of tableheader.js and also included some code to get this working: #787670: Clean up tableheader.js
Comment #43
casey CreditAttribution: casey commentedI opened another issue containing a generic solution: #800270: Anchor/focus hidden beneath toolbar/tableheader (CKEditor full screen menu).
Comment #44
carlos8f CreditAttribution: carlos8f commentedI've noticed this bug recently, and it's a pain, especially with the per-row permission links on the modules page.
Looks like we have some issue inflation here: we also have #787940: Generic approach for position:fixed elements like Toolbar, tableHeader (adds displace.js after being reverted), #800270: Anchor/focus hidden beneath toolbar/tableheader (CKEditor full screen menu) (seemingly improves displace.js, which no longer exists), #567754: Wrong anchor adjustment in tableheader.js (patches tableheader.js, but from 2009) AND this issue. Gah! I'd like to see the effort consolidated, if we're going to squash this bug.
Comment #45
Everett Zufelt CreditAttribution: Everett Zufelt commentedSee also #841184-57: "Skip to main content" link doesn't work correctly in the overlay. Marking Major as this is not critical, but can really make things difficult to find / use, like the UI control to disable the Overlay.
Comment #46
Everett Zufelt CreditAttribution: Everett Zufelt commentedTagging
Comment #47
mgifford#41: toolbaranchor.patch queued for re-testing.
Comment #49
sun.core CreditAttribution: sun.core commentedSo it seems this issue is a straight duplicate of #800270: Anchor/focus hidden beneath toolbar/tableheader (CKEditor full screen menu)
Lots of brainpower on both issues, so pretty please review both issues in detail before marking one of both as duplicate. The other one sounds more generic and thus, more correct.
Comment #50
mgiffordI just wanted to update the patch of #41. It doesn't seem to break anything, but I'm not sure if of it works either. The whole section for misc/tableheader.js was substantially rewritten so this section no longer is findable.
Comment #51
zeta ζ CreditAttribution: zeta ζ commentedI only saw this issue on friday but the problem has annoyed me before then.
This patch implements a css-only solution inspired by alistapart.com article. It might need temporarily switching off js to ensure no interference – I’m not sure how much of this js is in head.
A couple of screen-shots as well – note position of scrollbar
I’ve added a page-wrapper to seven’s page.tpl.php, à la bartik — Is there a better way to inject this <div> from toolbar?
Overlay will need more work.
Comment #52
sunComment #53
casey CreditAttribution: casey commentedWrapping all page content like patch in #51 could be a solution, but then either themes are required to include a wrapper in page.tpl.php that or at least support that (we could wrap content in template_(pre)process_html() or using Javascript; css selectors and other scripts have to account for the possibility).
Anyways it could be much easier to implement/maintain than the bloated fix-fixed-positioning-script in #787940: Generic approach for position:fixed elements like Toolbar, tableHeader.
Comment #54
The1design.cn CreditAttribution: The1design.cn commentedUse a table, let them in table box fix forever maybe
Comment #55
sunRestoring tags.
Comment #56
catchDon't think we can get away with adding the wrapper markup for D7, either in Seven or requiring other themes to do it.
Comment #57
Bojhan CreditAttribution: Bojhan commentedCan anyone tell me what is stopping us from getting this fixed? It looks like #787940: Generic approach for position:fixed elements like Toolbar, tableHeader provides a generic approach, this issue needs to implement?
Comment #58
mgiffordI'm marking this as a duplicate for now. It certainly seems to be in my review. It's also referenced from 787940 which is good.