when the uri fragment identifier links to an element in a collapsed fieldset, i wish the "collapsed" class were removed from that fieldset, so the browser can move the view port to that element and the element is visible

currently the "collapsed" class is removed from fieldsets which contain elements matching the selector, 'input.error, textarea.error, select.error', so that errors are visible. this patch adds ":target" to that selector, so the "collapsed" class is also removed from fieldsets which contain the target of the uri fragment identifier.

in other words, given the markup,

[...]

[...]

[...]

[...]

- when accessed with the uri, http://...#foo, the "collapsed" class will be removed from the fieldset, so the browser can move the view port to the div and the div is visible

CommentFileSizeAuthor
#11 collapse-anchor.patch779 bytescasey
#3 collapsetarget.patch796 bytescasey
#1 535966.patch718 bytesjablko
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jablko’s picture

FileSize
718 bytes

oops, guess that markup shoulda been,

[...]
<fieldset class="collapsible collapsed">
[...]
<div id="foo">
[...]
</fieldset>
[...]

Status: Needs review » Needs work

The last submitted patch failed testing.

casey’s picture

FileSize
796 bytes

I agree on the idea.

The uri fragment identifier however can easily change. So this patch isn't complete. We could use the hashchange event. For cross-browser compatibility we would need jquery.ba-bbq.js. Needs some discussion.

casey’s picture

Status: Needs work » Needs review

Lets forget hashchange for a moment and focus on the easy part first.

Patch still applies.

casey’s picture

Issue tags: +Usability

tagging

Dries’s picture

I'm confused by the comments above. Are you recommending we commit this 'as is' or are you saying we need to do more work on it?

casey’s picture

Oh, I am sorry. Yes I mean commit this 'as is'. It is functional as long as the hash doesn't change.

The part that doesn't work is when you click an anchor-link that is inside an collapsed fieldset, the fieldset won't automaticly open.

Dries’s picture

Status: Needs review » Fixed

Committed to CVS HEAD. Thanks.

Kiphaas7’s picture

Status: Fixed » Needs work

Got this error in firebug console:
uncaught exception: Syntax error, unrecognized expression: Syntax error, unrecognized expression: target

After debugging, it turns out the following line is responsible:

      if ($('.error, :target', $fieldset).length) {

Which is exactly what this patch changed...
Since the :target selector is not listed in the api (http://api.jquery.com/category/selectors/), I don't think it is actually supported by jquery?

Maybe some code of the link below can be used instead..
http://stackoverflow.com/questions/1451292/what-does-selector-ahref-mean...

casey’s picture

I am pretty sure it worked. Apparently jQuery 1.4 doesn't support it any more. I'll have another look today.

casey’s picture

Status: Needs work » Needs review
FileSize
779 bytes

This should work.

tobiasb’s picture

Status: Needs review » Reviewed & tested by the community
Kiphaas7’s picture

Status: Reviewed & tested by the community » Needs review

Code looks good, but is there some page to test this? Only page I thought of was the modules page in core, but that fieldset is already visible.

Also curious if this goes well with overlay fragments.

It went in once with code that totally broke collapsible fieldsets, let's not rush in another one...

casey’s picture

Kiphaas7’s picture

Status: Needs review » Reviewed & tested by the community

patch works.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

Status: Fixed » Closed (fixed)
Issue tags: -Usability

Automatically closed -- issue fixed for 2 weeks with no activity.