- Status changed to Postponed: needs info
over 1 year ago 1:10pm 23 June 2023 - ๐ฉ๐ชGermany Anybody Porta Westfalica
Is this still an issue with 2.0.x? If yes, please update the version and set the status active again with clear steps or (best) with a test showing what's broken.
2.0.x is the active development branch.
If nobody replies, we should assume this is fixed and close this issue outdated.
Thanks!
This is still an issue with 2.x. Just installed it on my fresh D10 site and I'm seeing a continually duplicating "Insert selected" button appearing.
- Status changed to Active
over 1 year ago 6:12am 21 July 2023 - ๐ฉ๐ชGermany rgpublic Dรผsseldorf ๐ฉ๐ช ๐ช๐บ
Has anyone in the meantime found at least the reason for why this happens?
- ๐ฉ๐ชGermany rgpublic Dรผsseldorf ๐ฉ๐ช ๐ช๐บ
Okay, I've looked into this further:
1) "Drupal\media_library\Plugin\views\field\MediaLibrarySelectForm" adds the "Insert selected" button at the bottom of the rendered view
2) Because of the "drupalAutoButtons" feature for modal dialogs which is enabled by default, any buttons which appear in the dialog's content area are moved out of there and into the actions bar at the bottom.
3) Views Infinite Scroll doesn't just add rows but adds a whole new rendered view page which includes another button. So after click "Load more" once, we have now: [Some rows] + [Button] + [More rows] + [Button]. The drupalAutoButtons features rips out all the buttons from the DOM and places them next to each other at the bottom.
4) And so on...I found one solution (which is perhaps a bit better than just hiding the extra buttons with CSS) to insert the following line in js/infinite_scroll.js :
var $newRows = $newView.find(contentWrapperSelector).children(); var $newPager = $newView.find(pagerSelector); $newRows.find('.button.media-library-select').remove(); // <== This is new
Of course, this is still not really the best solution because the extra buttons shouldn't be generated in the first place.
I guess we should wait for #3098132 to be resolved here because we actually want to only replicate the rows - not the whole view with HTML form tags etc. After this issue is resolved, I guess this issue here should get resolved automatically without any extra JS mumbo jumbo, because we won't replicate the insert button anymore but just the rows.Another side-effect of this btw, is that the fade-out effect doesn't work for the media thumbnails loaded with "Load more". Usually if I can select only one media file (cardinality 1) and I subsequently select only one, all the other thumbnails will get a darken / fade-out effect. This also won't work because we add a whole new form so the items which need to be faded-out are now spread across multiple forms. This might also get resolved with #3098132 but perhaps extra work is needed. We'll see. Just wanted to note that this is sth. to keep track of.