Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
With the Upload, Web, and Library tabs enabled, after uploading an umage using the upload tab, the user gets automatically switched to the Library tab once the ajax file upload progress bar has completed. This is confusing as the uer has no idea what has happened of if there image has been uploaded or not (it doesn't show in the Library tab). Switching back to the Upload tab shows that the image has been uploaded, and clicking save works as expected.
Comments
Comment #1
mrfelton CreditAttribution: mrfelton commentedA similar thing happens when using the pagers at the bottom of the Library tab. As soon as the ajax callback has completed and the Library content is updated to show content from the next page, the user is automatically switched to the Web tab. Clicking back to the Library tab shows the updated Library view.
So, it seems like it may be a problem with ajax callbacks in general, causing the active tab to switch unexpectedly.
Comment #2
mrfelton CreditAttribution: mrfelton commentedLooks related to #1307596: Media browser loads the wrong tab after a form validation error
Comment #3
mrfelton CreditAttribution: mrfelton commentedAlso related #1802026: Ajax callbacks in the media overlay cause the active tab to switch tab unexpectedly
Comment #4
clemens.tolboom#3 links is to this same issue
Also related #1551376: YouTube Tab: When apply searching, next or previous button it does not retain tab when loading result
Comment #5
clemens.tolboomIn media_youtube: #1551376-7: YouTube Tab: When apply searching, next or previous button it does not retain tab when loading result @Aaron added a solution for the tab provider.
In #1551376-8: YouTube Tab: When apply searching, next or previous button it does not retain tab when loading result I added comment for the 'refresh' flow copied here as Media should keep the tab state.
Media must manage the Tab state like this:
(http://stackoverflow.com/questions/4299435/remember-which-tab-was-active...)
I'm not sure we need setter and getter as we have set the #fragment as above. Is that #fragment kept when submitting through one of the tab forms? I haven't found any jQuery UI Tab related javascript.
(http://api.jqueryui.com/tabs/#option-active)
Comment #6
clemens.tolboomAttached patch solve this for a few tabs which triggers media_form_alter.
It works for media_youtube Search button. Not for #1551376: YouTube Tab: When apply searching, next or previous button it does not retain tab when loading result
It fails for Library or My files as the hook_form_alter is not involved for those page.
It needs more work but I need a review :)
Comment #7
clemens.tolboomPatch from #6 works nicely.
Tested against:
- Upload (it is the first tab after all)
- YouTube
- Web
- Remote URL
- Library
- My files
Comment #8
gmclelland CreditAttribution: gmclelland commentedJust tested the patch in #6 and everything seems to work correctly. Great job!
Comment #9
slashrsm CreditAttribution: slashrsm commentedHm... I'm unable to reproduce this issue on latest -dev. Can anyone help me? Do I have to do anything special to see this error?
Comment #10
gmclelland CreditAttribution: gmclelland commented@slashrsm - You can see the problem when you have the media_youtube module installed. On the youtube tab in the media browser try to search for something. The mediabrowser iframe will reload, but the tab will no longer be on the youtube tab it will be on the upload tab.
This patch solves the problem by keeping the user on the youtube tab after searching.
Hope that helps.
Comment #11
slashrsm CreditAttribution: slashrsm commentedGreat job!
As already mentioned in #6 it fixes media_youtube, but it does not fix views pager if not using AJAX (Library, My files, ...). I'm wondering if there exists any other, more general solution....
Comment #12
bneil CreditAttribution: bneil commentedHere is another tab-related issue #1934226: Hide tabs when plugins are on step > 1.
Comment #13
clemens.tolboomTnx for testing.
Regarding non ajax views: @slashrsm you are right this should be more general. Maybe we could intercept at the plugin level? I could use some hints.
@bneil thanks for the XREF.
Comment #14
clemens.tolboomTagging UX
Comment #15
tobiasbThis iss the patch for the current "2.0-unstable7" Version. Useful for drush make or so.
Comment #16
clemens.tolboomComment #17
ParisLiakos CreditAttribution: ParisLiakos commentedwe could use a cookie and be done with it..it would work on all occasions
Comment #18
timbrandin CreditAttribution: timbrandin commentedComment #20
timbrandin CreditAttribution: timbrandin commentedTesting on unstable7 instead.
Comment #21
timbrandin CreditAttribution: timbrandin commented#15: media-1802026.15.patch queued for re-testing.
Comment #22
timbrandin CreditAttribution: timbrandin commentedHere's a similar but improved solution, that stores the currently active tab in the Drupal.media var.
Comment #23
timbrandin CreditAttribution: timbrandin commentedAdded so that when the active tab is selected the resizing works as expected.
Comment #24
crazybutable CreditAttribution: crazybutable commentedWhile investigating this patch, before I applied it, I tested the original issue and could not reproduce the bug with the library pagers.
Comment #25
jlk4p CreditAttribution: jlk4p commentedInstalling the first, media-unexpected-tabs-1802026-6.patch, worked. But it did not resolve the problem. Installing any of the other patches after that seemed to have an issue with the existing code. I went back and downloaded the module (7.x-2.0-unstable7) again and reinstalled so I can try this again. Then I installed just the last patch, media-browser-ajax-active-tab-issue-1802026-23, without an error. But it doesn't appear to return to the same tab when submitted.
Do I need to apply all the patches in this thread for the issue to get resolved?
Comment #26
KarlKedrovsky CreditAttribution: KarlKedrovsky commentedTested patch on #23 using the current media_dev distribution and it worked as expected.
Comment #27
Dave ReidCommitted #23 to 7.x-2.x: http://drupalcode.org/project/media.git/commit/83d93ab. Thanks everyone!
We should probably look if this needs to be backported to 7.x-1.x as well.
Comment #28
torotil CreditAttribution: torotil commentedI just tried this with media 2.0-alpha1 and media_youtube-2.0-rc3. For me the patch doesn't work at all. Watching the variable Drupal.media.browser.activeTab revealed that it is always set to 0 when loading the form - regardless of which tab I select.
Comment #29
torotil CreditAttribution: torotil commentedIt's the non-ajax part (see #6 or #15) that's still unsolved.
Comment #30
ParisLiakos CreditAttribution: ParisLiakos commentedfor the non-ajax part a $.cookie would be needed to be set
this is something i have used for a client project in an attach method:
Comment #31
torotil CreditAttribution: torotil commentedHere is a patch that keeps the page using the window.location.hash. It works with AJAX as well as without.
+It makes the selectErrorTab function obsolete.
Comment #32
torotil CreditAttribution: torotil commentedHere is the same patch for 7.x-1.x.
Comment #33
torotil CreditAttribution: torotil commentedComment #34
bneil CreditAttribution: bneil commentedComment #35
aaron CreditAttribution: aaron commentedThis works for me.
Comment #36
jlk4p CreditAttribution: jlk4p commentedThe patch in #31 above fixed the issue with Media 7.x-2.0-alpha2 for me.
Comment #37
hefox CreditAttribution: hefox commentedPatch no longer applies to 2.x-dev
Comment #38
torotil CreditAttribution: torotil commentedHere's a re-roll of the patch. Now also works with jQuery-UI >= 1.10.
Let's see how many RTBCs and re-rolls this needs before it gets in.
Comment #39
torotil CreditAttribution: torotil commentedComment #40
torotil CreditAttribution: torotil commentedYet another re-roll.
Comment #42
torotil CreditAttribution: torotil commentedComment #43
SiliconValet CreditAttribution: SiliconValet commentedThe latest patch (#42) doesn't work in the latest 7.x-2.x-dev release. That is, after applying the patch, when I get the popup and select the library, clicking the next button (pager item) sets the upload tab (for me anyway - seems it could be any tab for others) as the active tab.
In short, no difference before or after the patch.
UPDATE: In playing with it, it seems it's not returning the index and resorts to '0'. For my personal use, I've set it to the index I need. I found this near line 49 (after patch #42) here: "Drupal.media.browser.tabFromHash = function () {"
Comment #44
hefox CreditAttribution: hefox commentedI got a patch working for the settings of jquery update I'm using and the alpah3, which may illustrate why some people are having issues with this patch
window.location.hash doesn't work cross browser; I was completely unable to get it to work in chrome, was always empty.
ui.tab is not set in some jquery ui versions, it's like nextTab, but might as well use a selector if possible.
I changed it to store the tab info in an attr, after trying various things including jquery.data and having none of them persist. I think that is a bad idea but works.
Comment #45
hefox CreditAttribution: hefox commentedComment #46
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedthe patch no longer applies to dev media.
Comment #47
David_Rothstein CreditAttribution: David_Rothstein commentedHere's a reroll which applies to the latest 7.x-2.x code. Seems to work (based on light testing).
Comment #48
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedthis patch works well. thanks!
Comment #49
alex.skrypnykPatch in #47 work really well. It also handles jQuery <1.9 and >=1.9 and jQuery UI < 1.8 and >= 1.8
Comment #52
aaron CreditAttribution: aaron commentedCommitted to http://drupalcode.org/project/media.git/commit/b534d3e.