On 31/05/2019 6:04 pm, Mike Dewhirst wrote:
> On 30/05/2019 8:22 pm, Mike Dewhirst wrote:
>> I just encountered a weird UI glitch[1] in the Admin after upgrading
>> to Django 2.2.1
>>
<snipped to cut to the chase>
> I have now discovered the problem described earlier is more generic as
> follows:
>
> 1. For *any *ForeignKey or ManyToManyField in the Admin, if you click
> (SHOW) and there is already an existing related record it will open up
> nicely. No sign of any bug.
>
> 2. For any such related item if you "Add another <whatever>" and click
> (SHOW) the Admin will reposition to the top of the page instead of
> opening the collapsed fields.
>
> 3. I have disabled all my own css
>
> 4. There is no js in any of my static dirs - relying entirely on
> Django's js.
>
> 5. I haven't changed the Admin fieldsets 'classes': ('collapse',),
>
> 6. The problem goes away if I downgrade to Django 2.1.8
Back in 2.2.1 ...
7. Results are identical in both Chrome and Firefox
8. Commenting out lines 48, 49 and 50 in
contrib/admin/static/admin/js/collapse.js [2] causes the same problem
for 1 above. I really don't know javascript but it seems to me
toggleFunc isn't toggling Hide / Show correctly *when there is an
unsaved empty related record*. See toggleFunc from collapse.js [3]
[2]
48 for (i = 0; i < toggles.length; i++) {
49 toggles[i].addEventListener('click', toggleFunc);
50 }
( I did try line 48 as ... for (var i = 0; i < toggles.length; i++) {
... but no cigar)
[3]
33 // Add toggle to anchor tag
34 var toggles = document.querySelectorAll('fieldset.collapse a.collapse-toggle');
35 var toggleFunc = function(ev) {
36 ev.preventDefault();
37 var fieldset = closestElem(this, 'fieldset');
38 if (fieldset.classList.contains('collapsed')) {
39 // Show
40 this.textContent = gettext('Hide');
41 fieldset.classList.remove('collapsed');
42 } else {
43 // Hide
44 this.textContent = gettext('Show');
45 fieldset.classList.add('collapsed');
46 }
47 };
Should I start a new project and try and demonstrate it there?
Thanks
Mike
>
> What code would be interesting in this case?
>
> Any hints?
>
> Thanks
>
> Mike
>
>>
>> Is there a best practice for ensuring I keep my projects up to date?
>>
>> Thanks
>>
>> Mike
>>
>> [1] With a m2m (self) adding another instance clicking on the {SHOW}
>> link just relocates to the top of the page. Has to be a jQuery thing
>> doesn't it?
>>
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/daa13769-bbf0-4ca9-cf5d-b094ce4aa640%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment