Skip to content

[#31514] Changing list formfields to use a default class "advancedSelect" for Chosen support #3721

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from

Conversation

Bakual
Copy link
Contributor

@Bakual Bakual commented Jun 4, 2014

This is an updated and bit improved version of #1620.
Originally it started as a way to automatically disable Chosen when there are a lot of options. It expanded a bit from there.
There are also other PRs with have different ways proposed to solve similar issues: #2018, #1609

See also Feature Tracker:
http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=31514

Issue

Chosen has performance issues when facing a huge amount of options. Since the menu item view (like most views) use JHtml::_('formbehavior.chosen', 'select'); to load Chosen on every ``, this can break the creation of menu items.
This PR makes use of the default behaviour ofJHtml::_('formbehavior.chosen');which triggers on the class`.advancedSelect`.

Proposed Solution

This PR will do a few things:

  • Changing the list, groupedlist, accesslevel and componentlayout formfields so it defaults to the class "advancedSelect" if no class is given. Currently there is no default at all.
  • Changing the list formfield so it removes this class if there are more than 10'000 options.
  • Changing the call JHtml::_('formbehavior.chosen', 'select'); to use the default JHtml::_('formbehavior.chosen'); in the menu item view.

For now, the scope is only the menu item edit form, however it would be possible to expand it to other places as well if we decide to follow that route. Especially if we use a default class within the fields, we don't have to edit 100+ XML files to add the class there.

If a developer decides he doesn't want to use Chosen for a specific field, he could just add a random class to the field in the XML and Chosen wouldn't be loaded anymore.

There may be better ideas of course 😄

Testing

  • Make sure the menu item edit screen looks the same before and after the patch. Especially the dropdown lists should look and behave the same (using Chosen).
  • Try testing with some big data, like 10'000 categories and check that the category selection doesn't use chosen anymore.

@Bakual Bakual changed the title Changing list formfields to use a default class "advancedSelect" for Chosen support [#31514] Changing list formfields to use a default class "advancedSelect" for Chosen support Jun 4, 2014
@prices
Copy link

prices commented Sep 14, 2014

I am working on a user plugin where I am running into similar problems. I have a custom form field that has two multiple select fields and buttons to move things between them. The formbehavior.chosen multiple select boxes kind of kill the point of doing that, because you can't see what is in either of the fields unless you click on them. What I ended up doing in the component that goes with the plugin is using JHtml::_('formbehavior.chosen', 'select:not(.plain)'); which defaults to all of them, unless I use the class 'plain' on the fields. In this way, I can easily make the default to use the chosen behavior, but choose not to use it, if I don't want it.

I would like to see something like this in com_users, so my dual select boxes look reasonable again. I am posting this here because the original poster is suggesting doing his change all over Joomla. If you want, I can post a new bug.

This comment was created with the J!Tracker Application at http://issues.joomla.org/.

@n9iels
Copy link
Contributor

n9iels commented Feb 28, 2015

Can you please give us an method to make 10000 categories so we can test your patch?


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/3721.

@brianteeman
Copy link
Contributor

You can use com_overload from @nikosdion
https://github.com/nikosdion/com_overload
On 28 Feb 2015 12:42, "Niels van der Veer" [email protected] wrote:

Can you please give us an method to make 10000 categories so we can test

your patch?

This comment was created with the J!Tracker Application
https://github.com/joomla/jissues at issues.joomla.org/joomla-cms/3721
http://issues.joomla.org/tracker/joomla-cms/3721.


Reply to this email directly or view it on GitHub
#3721 (comment).

@Bakual
Copy link
Contributor Author

Bakual commented Nov 4, 2015

Closing due to lack of interest.

@Bakual Bakual closed this Nov 4, 2015
@Bakual Bakual deleted the ListChosen4 branch November 4, 2015 08:53
@brianteeman
Copy link
Contributor

Any chance of resurrecting this

@Bakual
Copy link
Contributor Author

Bakual commented Apr 13, 2016

If there is any interest in it, I (or anyone else) can recreate it easily.

@brianteeman
Copy link
Contributor

If its easy to recreate I am definitely interested in seeing it

On 13 April 2016 at 18:09, Thomas Hunziker [email protected] wrote:

If there is any interest in it, I (or anyone else) can recreate it easily.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#3721 (comment)

Brian Teeman
Co-founder Joomla! and OpenSourceMatters Inc.
http://brian.teeman.net/

@Bakual
Copy link
Contributor Author

Bakual commented Apr 13, 2016

@brianteeman See #9901 (waiting for Travis to fail, need likely to fix some Unit Tests).

@Bakual Bakual deleted the ListChosen4 branch April 13, 2016 17:47
@brianteeman
Copy link
Contributor

Thanks - i will take a look tomorrow when I sober up

On 13 April 2016 at 18:47, Thomas Hunziker [email protected] wrote:

@brianteeman https://github.com/brianteeman See #9901
#9901 (waiting for Travis to
fail, need likely to fix some Unit Tests).


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#3721 (comment)

Brian Teeman
Co-founder Joomla! and OpenSourceMatters Inc.
http://brian.teeman.net/

@xjdfhbv
Copy link

xjdfhbv commented Jul 11, 2016

There absolutely needs to be a way for select lists to "opt out" of being modified by Chosen. There will always be occasions where Chosen either doesn't work well, or isn't appropriate. I have just had to add some Javascript to one of my extensions to prevent a select list being hit by Chosen, but it's not pretty. The Chosen initialisation should be modified to always exclude selects that have a certain class, e.g. "not_chosen", or something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants