#36336: Incorrect size of first autocomple in Inlines with "collapsed" class (on
chromium based browsers?)
-------------------------------------+-------------------------------------
Reporter: Michał Pokusa | Owner: (none)
Type: Bug | Status: new
Component: contrib.admin | Version: 5.1
Severity: Normal | Resolution:
Keywords: autocomplete | Triage Stage: Accepted
collapse size inline |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Comment (by Michał Pokusa):
I don't believe updating the `select2` would do anything, because I am
nearly sure the problem is in the `Element.outerWidth()` that is still
used be the latest version.
Additional notes say:
''"The value reported by .outerWidth() is not guaranteed to be accurate
when the element or its parent is hidden."''
https://api.jquery.com/outerWidth/#:~:text=The%20value%20reported%20by%20.outerWidth()%20is%20not%20guaranteed%20to%20be%20accurate
Inlines with "collapse" are hidden by default, because they are inside
<details> tag, so that is probably why the `Element.outerWidth()` has
problem calculating the correct width. That said, I am not sure why other
ones are calculated, but the fact that it is always the first one that has
wrong size suggest that maybe there is some kind of side effect to using
it for the first time.
One way to fix this, without modifying the `select2` code , is hard coding
<details open> and manually closing it using JS later, after initializing
all autocomplete widgets.
This is how the old "collapse.js" used to do it, but using <div> instead
of <details> tag.
As a proof of concept I hard coded `<details open>` in `stacked.html` and
`tabular.html` and added `this.querySelector(":scope > fieldset >
details")?.removeAttribute("open");` in `inlines.js` and it seems to solve
the problem.
My concern is that it would flicker on page load, but as said before,
`collapse.js` worked the same way.
PS
Also, maybe this could be a good moment to add support for "open" class,
so that it is possible to make a fieldset collapsible, but opened by
default.
https://stackoverflow.com/questions/61220704/how-to-make-all-the-inlines-
collapsible-items-in-django-admin-to-default-open
https://stackoverflow.com/questions/1766864/django-admin-add-collapse-to-a
-fieldset-but-have-it-start-expanded
--
Ticket URL: <https://code.djangoproject.com/ticket/36336#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/django-updates/010701965f3a22fc-f0135182-11a0-497d-9cb8-1521f274e312-000000%40eu-central-1.amazonses.com.