I have added a field for images to the basic article type, and I set the media browser as the widget. It all works fine, except for the window opens twice when I click "browse". The two windows display one on top of the other, so you can't tell until you move the window, hit ok, or close the top most window. The top most window has the overlay, once closed it disappears. It does it in both firefox and chrome, not major, but having to close the second window will get tedious. I've attached an image showing it.
It also does it with a basic install(Tested using simplytest.me for the media module).
Help fixing this would be appreciated.
This patch is largely the same as #18, but fixes some coding standards and includes the reverted revert commit mentioned in #15
| Comment | File | Size | Author |
|---|---|---|---|
| #116 | VirtualBox_IE8 - Win7_16_08_2016_10_33_03.png | 64.78 KB | oranges13 |
| #105 | media-fix_rebuild_bug-2534724-105-d7.patch | 1.05 KB | eelkeblok |
| #97 | media-fix_rebuild_bug-2534724-96.patch | 2.06 KB | eyilmaz |
| #95 | media-fix_rebuild_bug-2534724-95.patch | 2.05 KB | eyilmaz |
| #89 | media-object-keys-ie8.png | 9.46 KB | loopduplicate |
Comments
Comment #1
jstollerThis sounds like the same issue I posted in #2533312: Media field on Paragraphs item opens two overlapping browser modals. In my case the problem only seemed to appear when using a media field on a Paragraphs field item, but that doesn't seem to be the case here, so maybe this is a more general problem. Unfortunately, telling my users to just close the top browser window isn't a workable solution for me, so I won't be able to update my site until this is fixed. :-(
Comment #2
jlcraddock commentedIt does sound similar! I agree that it's probably a more general problem with this module, since I was able to duplicate it with a clean install of drupal and only this module with it's requirements installed. Oddly, if I close the top window, submit an image using the second and save the node, coming back in to edit it results in the expected behavior(one modal window). It also works just fine within the WYSIWYG editor. It seems like a simple "Check if we already have one open" is all that would be required, but I don't know enough about it to say for sure.
Comment #3
jstollerYeah, I noticed that I could sometimes get it to work on one field after successfully selecting an image in a different field. It was all very weird.
I just closed #2533312: Media field on Paragraphs item opens two overlapping browser modals as a duplicate of this issue. I got there first, but this deals with the more general case and we don't need two bug reports kicking around for the same thing.
Comment #4
leolandotan commentedI'm also having this issue but mine is it stacks perfectly on top of each other. I just noticed it when I open then close the pop-up window then it shows my the first pop-up window.
I updated from 7.x-2.x alpha-4 to beta-1.
Comment #5
jstoller@leolando.tan, the same with my windows. I assume the top window in the screenshot here was dragged to the side before the screenshot was taken.
Comment #6
leolandotan commented@jstoller Oh yeah! I just noticed now that it has the "draggable" title bar on the pop-up window. So far alpha-4 is working alright for the site. Just to add, I haven't tried doing some fixing that you guys did in the previous comments. :)
Comment #7
tobiberlinJust want to add that I am facing the same issue - with two perfectly overlapping windows. maybe it has to do with the enabled administration theme? In my case we use seven as admin theme
Comment #8
tobiberlinOk... tried several themes, nothing changed... tested 7.x-2.0-alpha4 and the error disappears
Comment #9
kfu commentedMaybe the problem seems to be the jQuery version: I installed the jQuery Update Module and set the version to something larger than 1.4. Then the problem has gone away. If you set it back to 1.4, the window opens twice.
I tried to track down the problem: In media.js the event for media-browser-launch seems to get called twice:
Configuration: Media 7.x-2.0-beta1, jQuery Update 7.x-3.0-alpha2
Comment #10
jlcraddock commented@kfu I just changed the jQuery version using JQuery Update from the default to v1.10 and the problem seems to have gone away! Has anyone else been able to replicate this fix?
Comment #11
PI_Ron commentedChanging to admin Jquery to 1.8 work for me.
My test case was:
- Multiple image field
- Duplicated window only happens on the second image you're uploading.
Comment #12
devad commentedSame for me. Thnx PI_Ron for sharing solution!
Comment #13
jkingsnorth commentedLikewise encountered the issue, updating to jQuery v1.8 was also a suitable workaround.
Comment #14
letrotteur commentedUpdating to jQuery 1.8 also worked for me.
Comment #15
devin carlson commentedI've reverted the commit which broke this for older versions of jQuery.
Comment #16
seren10pity13 commentedHi, I'm reopening this issue as upgrading jQuery is workaround, not a solution :
I never use jQuery versions over 1.5 in admin because it breaks views UI, and I'm probably not alone in that case.
In js/media.js l. 19 :
The var
selectoris an id string given by the function each(), and should refer to an unique object, but the requested id is used twice in the html dom, which should not be.The id is used in a
<div>for the .media-widget wrapper, which is what media.js is expecting to use, but it's also used in the upload form-text<input>field.$(selector, context) returns an array instead of a unique object, and that's why the function is run twice.
These 2 identical id's are here because of that litte change in media.module l. 719 :
As it's a right thing to have a label associated with a field, let's change the settings id returned to the js script, and the div wrapper id instead.
in media.module l. 825 :
in media.fields.inc l. 392 :
That's working fine for me.
Hope it helps !
Comment #17
seren10pity13 commentedIf you use #16 solution and have EPSA Crop module enabled, you'll have to make it get the fid from the right element.
in modules/epsacrop/js/epsacrop-media?js l. 25 :
Comment #18
markconroy commentedHi folks,
The code in #16 is working for me. I've made a patch of it that you might include in the next release of the module.
Comment #19
idebr commentedThe bug occurs in the latest stable release 7.x-2.0-beta1, but not in the latest -dev. It appears there is a not-so-subtle fix was committed:
http://cgit.drupalcode.org/media/commit/?id=cfb024205ef7682192b8357dc77a...
However, the media browser still produces invalid markup with duplicate ID's, as discovered by seren10pity13 in #16. Attached patch fixed the invalid markup and as a result, the mediabrowser window is only opened once.
I undid the reverted revert commit mentioned by Devin Carlson in #15.
This patch is largely the same as #18, but fixes some coding standards and includes the reverted revert commit mentioned in #15
Comment #21
idebr commentedComment #24
idebr commentedI updated the failing test to use the new selector.
Comment #25
andrewbelcher commentedI've added another related issue, #2551363: Selectors in mediaElement behavior are too vague. That has a patch that solves this issue from the javascript side of things.
Comment #26
legolasboI've reviewed the patch. Code looks clean to me and after manual testing I can confirm the problem is solved.
Before applying the patch:

After applying the patch:

Thanks idebr!
Comment #27
seren10pity13 commentedThanks for the patch !
Comment #28
dbazuin commentedI can confirm that this patch solves the issue.
Comment #29
tobiberlinCan also confirm that path from #24 solves the issue. Thanks a lot!
Comment #30
devin carlson commentedSome of these improvements have already made their way into our D8 code. I think I'd like to mirror the changes here for simplicity's sake.
Comment #31
strykaizerPatch in #30 is not working for media 2.x on D7 here.
Patch #24 does work though, so I suggest using that patch ;-)
Comment #32
jantoine commentedI had a similar experience as #31 until I cleared caches. At that point the browser began to work correctly! +1 for the patch from #30.
Comment #33
kumkum29 commentedFor me the problem is resolved with the patch from #30, i can choose a media in the library.
Now i have a problem with epsacrop.
Thanks.
Comment #34
esteinborn commentedI can confirm that #30 fixes this for me as well. Only one window pops up now. Running stock jQuery (1.4) from Drupal Core.
Thanks!
Comment #35
sam152 commentedHere is a reroll of #24 which is working for me. It looks like the JavaScript change already got in elsewhere.
Comment #36
Cale Bierman commentedThe patch from #35 is working for me on a basic install with the 2.0-beta1 release.
Comment #37
Cale Bierman commentedComment #38
bkno commented#35 works for me too. 2.0-beta1. Thanks!
Comment #39
naheemsays commentedManually applied patch on 2.0-beta1 - another confirmation that it works.
Comment #40
steinmb commented@nbz There is currently two patches here. #35 and #30 Witch one did you test? The patch is supposed to be applied to dev. so we must test against this, not latest stable.
Comment #41
kumkum29 commented+1
which patch should we use? I think the patch #35 should be more compatible with other modules ...(epsacrop ....)
Comment #42
Cale Bierman commentedFrom my testing, the patch #30 works on the latest dev release, but won't apply to stable (2.0-beta1).
The patch from #35 is working for me on both the latest dev and stable.
However, it seems like Devin wants to mirror what's going on in D8 in #30, so that should probably be the patch that is tested/RTBC'd.
Comment #43
steinmb commented+1 from me on #30.
Comment #44
naheemsays commentedI tested number patch in comment #35
Comment #45
steinmb commented@nbz could you also take #30 for a spin?
Comment #46
karlsheaPatch in #35 applied for me in 2.0-beta1 (make sure you're using patch -p1 ?), and it works (I cleared the caches right after applying).
Comment #47
legolasboAs stated before, we should be testing #30 against 7.x-2.x-dev. If that applies and solves the problem, report it here.
Comment #48
naheemsays commentedIve just applied #30 to media 7.x-2.x branch. It works.
Comment #49
tvhaute commented#30 worked for me as well! Thx
Comment #50
Rob_Feature commentedUsing #35 with success...RTBC based on all similar reports!
Comment #51
Arne Slabbinck commentedI had the same problem when using a field collection with a media browser inside an other field collection.
I've applied patch #35 to "7.x-2.0-beta1" and it seems to fix it, I still get a JS error after submitting the media browser overlay form:
Uncaught TypeError: Cannot read property 'node_form' of undefinedBut it doesn't seem to cause any problems (so far i've tested)
Comment #52
joelstein commentedPatch #35 worked for me with 7.x-2.0-beta1. Thanks!
Comment #53
dagomar commentedI have had problems with the patch in #35. If you have a custom form with a media field, it will stop working with this patch. The reason is that it uses another theme function in which the id is used. Note that it was this issue that caused all this trouble: #1734716. I have created a new patch that removes -upload from the theme function in media.module.
Comment #54
legolasbo@dagomar,
could you add an interdiff?
Comment #55
steinmb commentedPlease use #30, not #35. Apply it to HEAD. That is where the patch should work, not against latest stable.
Comment #56
kumkum29 commentedHello,
Patch #30 ? Patch #35 ?
if the recommended patch is the #30, do you think include this fix in the dev version? So, the question is closed.
For me the patch #35 is more useful with associated modules to media...(module for crop...)
Comment #57
steinmb commented@kumkum29 apply #30 against latest dev.
Comment #58
dmsmidt#30 +1
Comment #59
Andriy Mahats commented#53 +1
Comment #60
j1ndustry commentedInstalling the latest dev version of the media module worked for me. Seems like the patch has been applied to that version (7.x-2.x-dev 2015-Oct-01)
Comment #61
miroslavbanov commentedI have the "You have not selected anything!" problem. Using just Panels + fieldable_panels_panes. One "Image" field with "Media browser" widget.
Using latest stable without patches of:
Tried #53, and it did fix the problem.
Comment #62
andyd328#53 + 1
Thanks!
Comment #63
francescoq commentedWorks for me! Thanks!
Comment #64
dsnopekRTBC+1! We're now using this patch in Panopoly.
Comment #65
legolasbo@dsnopek, which of the patches is Panopoly using?
Comment #66
dsnopek@legolasbo: Panopoly is using #53
Comment #67
anybodyIs there an active module maintainer willing to apply the successfully tested patch?
This is really a mad bug happening in many of our projects. A final fix would help us a lot. Thank you for your great work!
Comment #68
cybernoid commentedThanks, #30 on current 2.x-dev works beautifully!
Comment #69
pieterdt commentedI confirm that #53 indeed fixes the problem that 'nothing was selected'.
Comment #70
jstollerI get the feeling this issue has drifted quite a bit since it's initial inception. Perhaps someone who understands what's going on here could update the issue summary, noting the two working patches (#30 and #53), and describing their different approaches? Then maybe we could get a module maintainer to look at this and make the final call. Just a suggestion.
Comment #71
partdigital commentedI agree, we should be using #30 and NOT #35 or #53.
#35 and #53 are work arounds for a bug that resides in media.js.
In theme_media_widget(), It truncates “-upload” from $element[‘#id’] to make it work with code in media.js. In reality though, it’s a flaw with the loop/selection logic in media.js.
#30 Updates the logic of media.js to fix the loop/selection logic. It removes the dependence on #element[‘#id’] and adds appropriate attach and detach functions. This was written as part of the D8 release and we should use this as the fix.
Comment #72
legolasboRe-uploaded the patch from #30 to prevent people that have not fully read the issue from using and commenting on the wrong patch. I've also hidden any non relevant files.
Comment #73
marc angles commentedtested #72 here and it fixes the double window and https://www.drupal.org/node/2111695 in the context of using media + inline_entity_form
Comment #74
dandaman commentedTested #72 and it seems to work for me.
Comment #75
web506 commented#35 worked for me. Thank you!
Comment #76
anybodyI think it's time to apply the patch to the dev branch soon and if possible create a new stable release together with other important patches?
Comment #77
stefan.r commented#53 works great along with beta1 for me. Requires a cache clear though!
Comment #78
jstollerThis is getting to be a little ridiculous. If everyone keeps testing different patches this thing is never going to be committed. @web506 and @stefan.r, did you also test the patch from #72 and find that didn't work? Or did you just test #35/#53? Can you test #72? It seems like the prevailing wisdom is that #72 is the way forward.
Can we get a maintainer to please decide which approach they want? At this point they've all be tested. :-/
Comment #79
pbonnefoi commented#72 worked for me. Thanks for the great job !
Comment #80
parasolx commented#72 also worked for me.
Comment #81
gmaxime commented#53 works with beta1! Thanks
Comment #82
jstoller@maximegaul did you also test #72? That is the patch currently being investigated here. Is there a problem with #72 that caused you to use #53?
Comment #83
stefan.r commented@jstoller it's just that some of us have to use tagged releases... and #72 doesn't apply to beta1 that's all :)
Comment #84
martijn de witApplied #72 manual to media 2.0-Beta1 and it works fine.
@stefan.r Why should #72 not apply to beta1 ?
Comment #85
jduff commentedManually applying #72 to beta1 worked for me.
Comment #86
dave reidComment #88
dave reidHere should be a version that applies to 7.x-2.0-beta1. Meanwhile I also committed this to 7.x-2.x.
Comment #89
loopduplicate commentedHi Dave,
Does it matter that Object.keys and forEach are not supported by IE 8? This patch makes media unusable on IE8; the attach button raises an error "Object doesn't support this property or method". Here's a screenshot
Regards,
Jeff
Comment #90
pandaski commentedRegarding Object.keys() issue and forEach on IE8 reported by @loopduplicate
I haven't tested it but this snippet should fix above issue
Find:
replace with:
REF: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global...
Comment #91
garchris commentedConfirming issue resolved in 7.x-2.x-dev version. Thanks!
Comment #92
Koen.Pasman commentedUpdating media module using the latest epsacrop on a File field breaks the 'Manage image crops' button. See also #2608818.
Ah, I see that this is related to the problem mentioned in #53 (the difference between the two patch approaches)
Comment #93
dmsmidtNote that the backport for beta-1 at #88 breaks the 'Remove' functionality. After browsing and adding an item, clicking the 'Remove' button will leave you with an text field and an 'Attach' button.
Comment #94
stevendeleus commentedThe patches in #30 and #72 solve the issue at hand, but create a problem when the form is rebuilt (cfr. #93).
I suspect this is due to the removal of the id. Please solve this before a new release, as this behaviour will break the release.
The patch in #35 does not have this problem.
Comment #95
eyilmazHere is a patch regarding which fixes the bug mentioned in #94. It's more or less a reroll of #35 but for the current code base.
Comment #97
eyilmazfixing tests
Comment #98
eyilmazComment #100
bceyssensThe changes committed in #87 break the upload widget as the element components are not siblings but children.
Comment #101
clairedesbois@gmail.comHi,
For the bug with form api which seems introduced by this patch, the problem is caused by something other.
I do an other issue and a patch.
Please, review my work.
https://www.drupal.org/node/2705001
Thank you.
Comment #102
oranges13The Patch in #100 worked for me RTBC
Comment #103
oo0shiny commentedMinor change to patch #96 so that the AJAX will convert the button from Attach to Browse.
Comment #105
eelkeblokI'm assuming the change to the tests in the above patch is a mistake, because the old version of the tests works fine with the patched code. Here's a version of 103 without the change to tests.
Comment #106
rcodinaUsing latest dev (patch by Dave Reid) solved the problem for me.
Comment #107
xaiwant commented@here patch #24 works for against 7.x-2.x applies and solves the problem
Comment #108
brockfanning commentedI think there is some confusion here because a fix has already been committed to dev, but it seems like there were related problems found afterwards. I'm seeing patches posted, since the dev commit in #88, that are completely different from each other. Would it make sense to split the newly found problems off into separate issues, so that we know what problem each patch is supposed to be fixing?
Comment #109
eelkeblokI was thinking the same thing, this is getting too confusing. Quickly scanning the issue since the commit suggests that there are three issues being discusses, first (since the commit) reported in #89, #92, #94, respectively.
Comment #110
oranges13I'm using the patch from #100 which fixes an apparent issue introduced from the commit to dev. It's working fine. I move that we can RTBC that patch.
Comment #111
brockfanning commented@oranges13, could you start a new issue that describes what the problem/fix is, and attach that patch to it?
Comment #112
oranges13@brockfanning I'm not sure to what you're referring. The patch in #100 fixes this issue as described for me (the media popup opening twice)
Comment #113
brockfanning commented@oranges13, just trying to help get things committed. If it's not clear to the module maintainers what's what, this will probably stagnate. You say #100 works, which is great, but there are other patches before and after #100 for seemingly different problems, including one that was even committed. Just my 2 cents, but it seems like a new issue would be the best way to make things clear for the maintainers. A description of how to recreate the problem would probably be helpful too. (I'm curious why I haven't encountered this problem.)
Comment #114
jstollerI'm pretty sure the original issue was fixed long ago. At least in dev. Then there were questions about how it was fixed, and tangential issues came up, and the whole thing got very confusing.
Comment #115
rob c commentedSo the next time: followup issue == New issue - with a reference back to the original issue. Thanks! (prevent chaos)
Proposal: people handling these additional issues: open up a new issue, reference this issue, so we can close this one. (also for future issues we will work on, i think it's much better if we isolate these, so when we are searching for the cause of something, we can look up the history a lil bit easier - and quicker!)
Comment #116
oranges13Just did a few tests to confirm what's going on. To clarify, I am using Media on a _production_ site, so I needed production level code. I did not use the dev versions on this site because the "beta" version was the current stable release.
When I made my comment on July 13, beta1 still had the double popup bug (see the screenshots on comment #26 for what that looks like).
My normal practice is to use the most up to date patch at the time, which was #100 when I got to this thread. The patch in #100 fixes the issue described in this thread for the version that I was using (beta1). I just confirmed this by using simplytest.me. If you use media-2.x-beta1 this bug is still present. The patch in #100 fixes that.
Comments after #88 (the fix which was committed) seem to indicate that it causes other problems or is incompatible with IE8. To test this, I just spun up a simplytest.me site with beta1 and the patch from #88 applied and tested it with IE8. I confirm that the patch in #88 DOES NOT WORK with IE8.
Media beta2 does not work with IE8 either (which I'm assuming contains the committed fix from #88).
Media beta1 with the patch from #100 DOES WORK with IE8.
Not that I use IE8 that frequently, but it's possible that others might. So the patch in #100 actually fixes this issue. The one that was committed only partially fixes it.
Comment #117
anybodyThank you very very much for your investigations @oranges13. This way we should get things fixed and this issue finally resolved.
I guess it would be best if @DaveReid will have a look at this again (from #86) and should decide how to proceed best. We could create an interdiff from #86 and #100 or perhaps the commit from #86 can be rolled back and the fix from #100 can be applied instead?
I'd suggest to create a new beta3 (EDIT: I wrote beta2 before (typo)) release then with both fixes included to finally fix it. Thank you all very much. Not let's wait for a maintainers decision how to go on...
Comment #118
rob c commented"I'd suggest to create a new beta2 release ... "
Not possible. The next release will be beta3. (thats just how it works)
"The one that was committed only partially fixes it."
Then it's still a followup. (might have fixed it 100% back then, something might have changed) (it didnt, lots has changed, and the original patch did not fix it fully, but still).
@oranges13 I've also tested a bit yesterday, i can confirm "Media beta2 does not work with IE8 either (which I'm assuming contains the committed fix from #88).", so it's actually still (partially) broken. Will test the rest later this week (if no one beats me to it).
Wonder about other TODOs for this issue.
Comment #119
jstoller@oranges13: I'd suggest posting a new issue specifically to address "Media broken in IE8." You can reference this issue as the parent issue, for historical context. Then post a patch against the dev release that undoes the committed patch from #72 and replaces it with the fix in #100.
Continuing to post patches against an older beta release, in a "fixed" issue with an already committed patch, isn't going to move anything forward. This thread outlived its usefulness six months ago.
Comment #120
izmeez commentedYes, this is very confusing.
Surely, any meaningful testing has to be done against the latest 2.x-dev code to allow things to move forward.
From what I can see, after the commit on 2016-Feb-15 the following three issues emerged:
1. Object.keys and forEach are not supported by IE 8
Comment #89 with a proposed fix in #90, that has NOT been rolled into a patch or tested.
2. changes committed in #87 break upload widget as the element components are not siblings but children.
Comment# 100 with patch, two lines.
3. The 'Remove' functionality broken
Comments# 93 reports, After browsing and adding an item, clicking the 'Remove' button will leave you with an text field and an 'Attach' button.
I cannot determine what the status of this is.
These can each be made into separate issues, especially #3.
Unless @DaveReid would suggest a different approach.
Comment #121
anybodyI'm finally fed up with this issue (xD)... so here are my manual testing results. Let's get this fixed and create a final patch...
#95 is broken
#97 changes tests which were correct
#100 does NOT work. The attach button is broken completely like in #116
#103 tests are broken
#105 works in tests, in IE8 and ALL other cases I could test manually! So the older patches are no more required.
#105 is against LATEST DEV. So that's the patch which should be tested as RTBC.
After all this discussion I'll now finally hide all patches except #105 and set this issue RTBC for #105 to take things forward.
It would be very very cool if we could get some more feedback on #105, please get it commited, create a new beta3 of it and create a new issue, if further problems appear.
Thank you all very much for this much too long discussion :P ;) :)
Comment #122
anybodyComment #123
anybodyPS: I can confirm #105 also works in combination with #951004: Allow selecting of multiple media items for a multi value media field in the same dialog (#197).
All previous issues in combination are gone now. WHAO :)
Comment #125
joseph.olstadPatch #105 no longer passes testing.
says #original_id is undefined
this is related to the patch.
Comment #126
joseph.olstadI'm not sure if this patch is necessary any longer. I haven't noticed this issue lately and I've been using 'media' a lot lately.
Comment #127
dsnopek@joseph.olstad I just retested without this patch, and it appears the problem is no longer happening! The old steps to reproduce that I had were to setup a content type with a multi-value file field using the media browser widget, and the 2nd time you clicked "Browse" it would open the dialog twice. But not happening for me with the latest 2.x-dev
Comment #128
joseph.olstadThanks @dsnopek
marking this as 'works as designed'
for anyone still observing this , please upgrade to media 7.x-2.0-rc3 or newer