8000 FIXED #5899 -- Allowed having the collapsible fieldset and inlines ex… by poncelettheo · Pull Request #19420 · django/django · GitHub
[go: up one dir, main page]

Skip to content

FIXED #5899 -- Allowed having the collapsible fieldset and inlines ex… #19420

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

poncelettheo
Copy link
@poncelettheo poncelettheo commented Apr 26, 2025

Allowed having the collapsible fieldsets and inlines, expended on page load.

Trac ticket number

ticket-5899

Branch description

This branch proposes to add new feature allowing to add the class colapse-open to an admin fieldset or an inline to allow it to be expended on page load.

Checklist

  • This PR targets the main branch.
  • The commit message is written in past tense, mentions the ticket number, and ends with a period.
  • I have checked the "Has patch" ticket flag in the Trac system.
  • I have added or updated relevant tests.
  • I have added or updated relevant docs, including release notes if applicable.
  • I have attached screenshots in both light and dark modes for any UI changes.

Copy link
@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello! Thank you for your contribution 💪

As it's your first contribution be sure to check out the patch review checklist.

If you're fixing a ticket from Trac make sure to set the "Has patch" flag and include a link to this PR in the ticket!

If you have any design or process questions then you can ask in the Django forum.

Welcome aboard ⛵️!

@poncelettheo poncelettheo force-pushed the ticket/5899-Allow-admin-fieldsets-to-be-collapsible-but-not-initially-collapsed branch 4 times, most recently from 43f109d to 63bab7a Compare April 26, 2025 14:02
Comment on lines 433 to 434
their visibility (use the ``collapse-open`` class to have the fieldset
initially expanded).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sentence seems confusing, from what I understand it's suggest using the collapse-open class instead of the collapse one. Don't we need to use both to have the detail open by default?

Suggested change
their visibility (use the ``collapse-open`` class to have the fieldset
initially expanded).
their visibility. Add the ``collapse-open`` class to have the fieldset
initially expanded.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We indeed need to use both to have the detail open by default. Your version is also clearer, i will modify the doc.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it all boils down to whether we want users to use "classes": ["collapse", "collapse-open"] or "classes": ["collapse-open"]. Depending on that is_collapsible_open might change to check self.is_collapsible

I think it's slightly better DX to have to pick "collapse" or "collapse-open" and not both but I'm not sure how django usually handles this kind of stuff

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good question, whether we need two classes or only one. I don't know if this helps, but it seems that both Bootstrap and Tailwind use two classes: one for the collapse in general and another to indicate if it's open.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably a good idea to align with bootstrap and tailwind since they are heavily used. Two classes seem like a good idea 👍

Comment on lines 2329 to 2330
class will be initially collapsed using an expandable widget (use the
``collapse-open`` class to have the inline initially expanded).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sentence seems confusing, from what I understand it's suggest using the collapse-open class instead of the collapse one. Don't we need to use both to have the detail open by default?

Suggested change
class will be initially collapsed using an expandable widget (use the
``collapse-open`` class to have the inline initially expanded).
class will be initially collapsed using an expandable widget. Add the
``collapse-open`` class to have the inline initially expanded.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We indeed need to use both to have the detail open by default. Your version is also clearer, i will modify the doc.

@poncelettheo poncelettheo force-pushed the ticket/5899-Allow-admin-fieldsets-to-be-collapsible-but-not-initially-collapsed branch from 63bab7a to b33549a Compare April 27, 2025 10:22
@sarahboyce sarahboyce added selenium Apply to have Selenium tests run on a PR screenshots 🖼️ labels May 9, 2025
Copy link
Contributor
@sarahboyce sarahboyce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this @poncelettheo, I added initial comments

My main concern is this is a really old ticket and I'm not sure this is worth it/really wanted. Personally I don't see the benefit, you could just not make it collapsible in the first place (so I am 0-).

I'm not 100% sure where would be the best place to gain clarity here. We have a new feature tracker: New Features but perhaps you can discuss this on the forum https://forum.djangoproject.com/c/internals/5 to get a few more opinions (the @django/steering-council might advise)

Comment on lines +130 to +131
if any(field in self.fields for field in self.form.errors):
return False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if any(field in self.fields for field in self.form.errors):
return False

We shouldn't need this

@@ -4,7 +4,7 @@
data-inline-type="stacked"
data-inline-formset="{{ inline_admin_formset.inline_formset_data }}">
<fieldset class="module {{ inline_admin_formset.classes }}" aria-labelledby="{{ inline_admin_formset.formset.prefix }}-heading">
{% if inline_admin_formset.is_collapsible %}<details><summary>{% endif %}
{% if inline_admin_formset.is_collapsible %}<details {% if inline_admin_formset.is_collapsible_open %}open{% endif %}><summary>{% endif %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of a new property we perhaps could do

Suggested change
{% if inline_admin_formset.is_collapsible %}<details {% if inline_admin_formset.is_collapsible_open %}open{% endif %}><summary>{% endif %}
{% if inline_admin_formset.is_collapsible %}<details {% if 'collapse-open' in inline_admin_formset.classes %}open{% endif %}><summary>{% endif %}

@@ -2325,7 +2326,8 @@ The ``InlineModelAdmin`` class adds or customizes:
A list or tuple containing extra CSS classes to apply to the fieldset that
is rendered for the inlines. Defaults to ``None``. As with classes
configured in :attr:`~ModelAdmin.fieldsets`, inlines with a ``collapse``
class will be initially collapsed using an expandable widget.
class will be initially collapsed using an expandable widget. Add the
``collapse-open`` class to have the inline initially expanded.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need .. versionchanged:: 6.0 notes and a release note

@tim-schilling
Copy link
Member

This issue does is very old and I can't find any community consensus about this addition. I would agree having it go through the new-features repo would make sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
screenshots 🖼️ selenium Apply to have Selenium tests run on a PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0