Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I think it could be useful if while I open a tab to change the URL according to tab's anchor
ex.
landing page: http://www.example.com/contact/13
I press the 2nd tab and URL changes to: http://www.example.com/contact/13#node_contact_full_group_more
With this functionality, when I will press back/next to my browser, it will change between tabs.
Comment | File | Size | Author |
---|---|---|---|
#28 | field_group-1747804-28.patch | 2.35 KB | douggreen |
#22 | 0001-Issue-1747804-by-gapple-toamit-Change-URL-using-anch.patch | 2.4 KB | grossmann |
#17 | horizontal-tabs.js_.patch | 1.97 KB | toamit |
#13 | field_group-1747804-13.patch | 2.15 KB | gapple |
Comments
Comment #1
nils.destoop CreditAttribution: nils.destoop commentedFunny, there was sprint yesterday, and we where discussing the same feature.
Comment #2
Hydra CreditAttribution: Hydra commentedYeah, just working on that, will be coming soon I hope
Comment #3
Hydra CreditAttribution: Hydra commentedWell, this was committed to 7.x-1.x, please don't use 2.x version, it is not supported!
The url changing actually just works for horizontal and vertical tabs! Maybe in a future version it will be working with any formatter.
Comment #4
okeedoak CreditAttribution: okeedoak commentedLooking at the code the html needs a class of "group-wrapper", probably on the vertical tabs group, but the closest I have using vertical tabs is "field-group-tabs-wrapper". If I manually add the class "group-wrapper" to the vertical tabs group the hashes are set correctly. Although the URL shows the new hash tags after changing tabs there is no other effect, at least using Chrome, Opera or Firefox. Reloading the page with the hash tag as part of the URL has no effect on which tab is active and the browser's back button doesn't change the active tab only the URL.
Comment #5
okeedoak CreditAttribution: okeedoak commentedThis code:
var fieldgorupID = 'field_group-' + $(this).attr('id') + ' ' + $(this).attr('id');
causes the ID to be applied twice with a space in between each instance. Is this the desired behavior?
Comment #6
okeedoak CreditAttribution: okeedoak commentedUnfortunately this violates the html5 spec stating that IDs can't contain spaces: http://www.w3.org/TR/html5/global-attributes.html#the-id-attribute
Comment #7
Stalski CreditAttribution: Stalski commentedThis is incorrect indeed. We'll check it asap
Comment #8
Hydra CreditAttribution: Hydra commentedI know, this is totaly bad coding. But this is the only way to achive this, without having the page jumping to the anchor! Since it is in DOM I think it's not that bad, but still eval. If anyone has a better solution, would be great!
Comment #9
dropfen CreditAttribution: dropfen commentedHi, can anyone tell me what's about the 7.x-2.x version? Will it be supported, what's the best way to do it by myself? Since we can use IDs to jump to the tabs directly (very nice feature), it's the missing puzzle piece ;)
Comment #10
Ony CreditAttribution: Ony commentedYes, seconding dropfen, would like to get more clarification on how to accomplish this
Comment #11
Zooney CreditAttribution: Zooney commentedI've found that in field_group/horizontal-tabs/horizontal-tabs.js, if you add the following after the call to "self.focus();" on line 80:
...you can do this. I mean, it's a quick hack, I'm not sure if there's a better way to manage this, or if someone should just submit this as a patch.
Comment #12
gappleThe attached patch changes the page url without affecting the scroll position. It also handles hash change events on forward/back navigation to update the selected tab.
IDs on the page should be unique, and the behaviour of this patch is undetermined if that is not actually the case.
This is probably something that should be configurable though, as I can see some people not wanting tab changes to be reflected in the navigation history.
Comment #13
gappleThe last patch had an issue with the initial load of the page and handling going back to the un-hashed url, so here's a bit of a better structured approach
Comment #14
Fabianx CreditAttribution: Fabianx commented**RTBM** - Works great here!
Comment #17
toamit CreditAttribution: toamit commentedThe older patch was out of sync with current file. Revised patch for horizontal-tabs.js
Comment #18
dercheffeI have the same problem like gapple in comment #12.
If I have two horizontal tabs, tab number 1 contains a separate link (e.g. inside a text field) linked to tab number 2. Now the user clicks on the link. The anchor is changing, but nothing else happens. The scroll position is still the same.
IMHO it's a good idea to fix this issue for improving the user experience.
Perhaps the revised patch of comment #17 should reviewed by the community, so I change the issue status.
Comment #21
scoff CreditAttribution: scoff commentedThe patch at #12 is still valid for D8.1.1. I don't know if it would apply as I've done it manually.
It doesn't matter much for node edit forms but it's very useful for frontend ui.
Comment #22
grossmann CreditAttribution: grossmann commentedI could not apply the patch #17 successfully on 7.x-1.x so I created a new patch. Nothing of the code has been changed and it seem to work so far.
Maybe someone can review and test the patch to get this committed or can be worked on.
Comment #24
Pete B CreditAttribution: Pete B at Deeson commentedThis patch will pass testing after #2871785: Tests failing in Drupal 7.50+ is committed.
Comment #26
Kris77 CreditAttribution: Kris77 commentedPatch #17 works fine for me too.
I use Field Group 7.x-1.5 and Drupal 7.54
Thanks @toamit
Comment #27
Kris77 CreditAttribution: Kris77 commented...It does not work when I submit the form.
If i click on submit button and there is an error, the page is loaded with the first tab...
Comment #28
douggreen CreditAttribution: douggreen at Tag1 Consulting commentedStripped ^M off of patch so that it applies.
Comment #29
pvasener CreditAttribution: pvasener commentedPatch is working for me.