There is a JS error if select2.js is used outside of addbiblio.tt: ReferenceError: select2Width is not defined Edit items view for instance.
Created attachment 114152 [details] [review] Bug 27124: JS error "select2Width is not defined" This patch changes the way select2.js checks for an existing value of the "select2Width" variable in order to avoid errors when it is undefined. To test, apply the patch and view various pages where the select2 plugin is used: - Basic MARC editor - Items edit - Batch item edit - Authority editor In each case check that the Select2 plugin works correctly to style fields like collection code and home library. On the basic MARC editor page these <select>s should have a width that adjusts as the browser window changes. On other pages the width should be fixed. Check the browser console and confirm that there are no JavaScript errors.
Created attachment 114163 [details] [review] Bug 27124: JS error "select2Width is not defined" This patch changes the way select2.js checks for an existing value of the "select2Width" variable in order to avoid errors when it is undefined. To test, apply the patch and view various pages where the select2 plugin is used: - Basic MARC editor - Items edit - Batch item edit - Authority editor In each case check that the Select2 plugin works correctly to style fields like collection code and home library. On the basic MARC editor page these <select>s should have a width that adjusts as the browser window changes. On other pages the width should be fixed. Check the browser console and confirm that there are no JavaScript errors. Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Seems to fix the console error in all the places!
The use of global variable `select2Width' can be easily avoided here by replacing it by a call to $.fn.select2.defaults.set directly after [% INCLUDE 'select2.inc' %] in addbiblio.tt Is there any benefit using this global variable ? (except for the shorter name)
Created attachment 114236 [details] [review] Bug 27124: JS error "select2Width is not defined" This patch changes the way select2.js checks for an existing value of the "select2Width" variable in order to avoid errors when it is undefined. To test, apply the patch and view various pages where the select2 plugin is used: - Basic MARC editor - Items edit - Batch item edit - Authority editor In each case check that the Select2 plugin works correctly to style fields like collection code and home library. On the basic MARC editor page these <select>s should have a width that adjusts as the browser window changes. On other pages the width should be fixed. Check the browser console and confirm that there are no JavaScript errors. Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Thanks for the quick fix, works as expected, no regressions found and passes a scripts. Passing QA
There is a pending question at comment 4. Owen, can you answer please?
(In reply to Jonathan Druart from comment #7) > There is a pending question at comment 4. Owen, can you answer please? If there is a better way to do it I'm happy for that solution to replace my patch.
(In reply to Owen Leonard from comment #8) > (In reply to Jonathan Druart from comment #7) > > There is a pending question at comment 4. Owen, can you answer please? > > If there is a better way to do it I'm happy for that solution to replace my > patch. Do you think that the suggested solution in comment 4 is a better solution ?
Created attachment 114300 [details] [review] Bug 27124: JS error "select2Width is not defined" This patch changes the default width paramter passed to the select2 plugin. This allows the basic MARC editor's Select2 widgets to be styled differently than on other pages. To test, apply the patch and view various pages where the select2 plugin is used: - Basic MARC editor - Items edit - Batch item edit - Authority editor In each case check that the Select2 plugin works correctly to style fields like collection code and home library. On the basic MARC editor page these <select>s should have a width that adjusts as the browser window changes. On other pages the width should be fixed. Check the browser console and confirm that there are no JavaScript errors. Update: Thanks to Julian for the suggested optimization
(In reply to Julian Maurice from comment #9) > Do you think that the suggested solution in comment 4 is a better solution ? Yes. I was making an incorrect assumption about when the default had to be set.
I tried even though I don't know well these places ^^" > - Basic MARC editor Is it cataloguing/addbiblio.pl ? Because I don't have the JS error before applying the patch. And I don't field a field that look like a Select2. > - Authority editor Which field?
Created attachment 114400 [details] [review] Bug 27124: JS error "select2Width is not defined" This patch changes the default width paramter passed to the select2 plugin. This allows the basic MARC editor's Select2 widgets to be styled differently than on other pages. To test, apply the patch and view various pages where the select2 plugin is used: - Basic MARC editor - Items edit - Batch item edit - Authority editor In each case check that the Select2 plugin works correctly to style fields like collection code and home library. On the basic MARC editor page these <select>s should have a width that adjusts as the browser window changes. On other pages the width should be fixed. Check the browser console and confirm that there are no JavaScript errors. Update: Thanks to Julian for the suggested optimization Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(In reply to Victor Grousset/tuxayo from comment #12) > I tried even though I don't know well these places ^^" > > > - Basic MARC editor > > Is it cataloguing/addbiblio.pl ? Because I don't have the JS error before > applying the patch. And I don't field a field that look like a Select2. Yes it is addbiblio, on this page the error is not shown, it's the only one page using select2 which does not has this error > > - Authority editor > > Which field? I bet you should define some authorized value category to a field manually... I've done it that way, because it was easier to me than trying to find some defined by default (which maybe even don't exist)
Created attachment 114441 [details] [review] Bug 27124: JS error "select2Width is not defined" This patch changes the default width paramter passed to the select2 plugin. This allows the basic MARC editor's Select2 widgets to be styled differently than on other pages. To test, apply the patch and view various pages where the select2 plugin is used: - Basic MARC editor - Items edit - Batch item edit - Authority editor In each case check that the Select2 plugin works correctly to style fields like collection code and home library. On the basic MARC editor page these <select>s should have a width that adjusts as the browser window changes. On other pages the width should be fixed. Check the browser console and confirm that there are no JavaScript errors. Update: Thanks to Julian for the suggested optimization Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
QA script passed Bug fixed, no regression found
Pushed to master for 21.05, thanks to everybody involved!
Pushed to 20.11.x for 20.11.01
Missing dependencies, not backported to 20.05