-
-
Notifications
You must be signed in to change notification settings - Fork 707
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
[BUU] Optimisation: long select lists repeated #12482
Comments
I think the consequence can be this behavior (easier to reproduce as super admin), if the user clicks several dropdowns within a short time: |
Hello @dacook , @filipefurtad0 , May I work on this issue ? |
Hi @cyrillefr yes feel free to pick, I will assign you: but it might be a tough one! Don't hesitate to ping David or Filipe again if you get stuck :) |
Hello @dacook , From what I have read from the source code, data that populate the selects come from the Rails controller. It is populated for each row in The So I guess your idea would be to on an event(click) to populate the select with the load once. But since, one cannot use the load once here, there would be the possibility to use some other method of the api, like the Also, when I talk about load once not possible, it is because I did not see some fetch/ajax in the source code and since you want to depart from Angular, my guess is that you would not want that. (I might be wrong though).
NB you mentioned the supplier lists, should the switch be applied to every tom-select list ? |
That would imply a new component that respond to click event or to pass an option to the existing one (if possible). |
~~Hi @cyrillefr - Really sorry for getting back on this late. I believe creating a new component for the tom-select specifically for fetching options from our server would be better. This could be more manageable I guess. You may refer to the below, I think we would want something like this:
Yes, exactly but it caches the searched results as well. Not exactly caching, it just appends the options in the DOM and then looks at them before making the API call. I think it's an optimized problem like this.
I think, applying this to every tom-select might be an overkill for now. However, a new component would allow us to reuse that specific tom-select for any place where we might face a similar issue. @dacook - What do you think about it?~~ |
Really sorry @cyrillefr I missed the use case above 😕 I guess then we need to use stimulus here. We could create a generic stimulus controller which would fetch all the options from the server by the specified path and then add those options in the specified tom-select's options dynamically. Please let me know if you have any questions. Thanks. |
Hello @chahmedejaz , Thanks for the comments. The important point in my opinion here would be to populate options upon some event (click), so that only the selects that are going to be used are populated. Except for the default I guess. Otherwise, populating every selects the way it is done currently or populating them by JS would be the same( except browser would work a bit more and server a bit less). Do you see things that way too ? |
@cyrillefr - Yes, this would indeed be a good solution in terms of having a clean DOM, however, this would cause some network delay on the UI before rendering the options. This might not be a good user experience to wait for the options upon clicking the dropdown.
I believe the main issue here is that the server is responding with a lot of duplicated options in the html. This is not an optimised solution in terms of response size. Makes sense? |
Hi both, thanks for discussing this. I'm sorry, I think I forgot to respond at the start of the week. The question is, what's the problem we're trying to solve? I have to admit I haven't measured any performance bottlenecks so I don't have an answer sorry. I raised it because I thought it was likely to cause problems, and it may have (see Filipe's post), but I haven't investigated yet. So I hadn't prioritised the task. But now I'm thinking about it... |
I guess there's a few levels we can optimise at, and I'm not sure what's practical. I think of at at a few levels:
Feel free to investigate further and try out what you think would be best. |
What we should change and why (this is tech debt)
Since adding dropdowns to the bulk edit screen (
/admin/products
with feature toggleadmin_style_v3
enabled), I've noticed the contents of the select lists are repeated for every row.It's not too bad for short lists. But a super-admin user has access to all suppliers on the system, which can be a very long list.
Proposed solution
Each type of dropdown shares the same list of options (apart from the
selected
attr), so we could probably load it once, then initialise the dropdowns with JS. I think Tomselect already has options for using a data source like that.The text was updated successfully, but these errors were encountered: