Skip to content
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

Fix display in dark theme #13

Merged
merged 3 commits into from
Nov 7, 2024
Merged

Conversation

hongquan
Copy link
Contributor

@hongquan hongquan commented Nov 4, 2024

Description

The orignal DALF has bad display in dark mode:

image

Here is after the fix:

image

Related Issue(s)

This pull request is related to issue(s) #.

Type of change

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

How Has This Been Tested?

Just replace original DALF with this fork.

Checklist

  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • Any dependent changes have been merged and published in downstream modules.

@hongquan hongquan requested a review from vigo as a code owner November 4, 2024 11:22
@vigo
Copy link
Owner

vigo commented Nov 4, 2024

hi @hongquan, thanx for the pr. tests are failing. can you please check?

@vigo
Copy link
Owner

vigo commented Nov 4, 2024

>                   assert (
                        f'<select class="django-admin-list-filter" name="{option_field_name}" '
                        f'data-is-choices-filter="{option_is_choices_filter}">'
                    ) in content

should be:

>                   assert (
                        f'<select class="django-admin-list-filter admin-autocomplete" name="{option_field_name}" '
                        f'data-is-choices-filter="{option_is_choices_filter}">'
                    ) in content

@hongquan
Copy link
Contributor Author

hongquan commented Nov 5, 2024

@vigo I have pushed the fix for test case, but somehow GH Action does not run.

@vigo
Copy link
Owner

vigo commented Nov 5, 2024

I see this, looks fine to me? if it's ok, i'll merge and release?

image

@hongquan
Copy link
Contributor Author

hongquan commented Nov 6, 2024

@vigo That display is not as expected.

Ah, the "by author" is as expected. The "by category" is not.

@vigo
Copy link
Owner

vigo commented Nov 6, 2024

@hongquan I'm a bit confused :)

by author is DALFRelatedOnlyFieldand operating system is in light mode, django is in dark mode:
image

by category is DALFRelatedFieldAjax and operating system is in light mode, django is in dark mode
image

i guess i should see by category (selection is open) as i've seen it in by author right? (this is your PR that i'm running)

@vigo
Copy link
Owner

vigo commented Nov 6, 2024

@hongquan found it, please add this part in django_admin_list_filter_ajax.html, add: data-theme="admin-autocomplete":

{% load i18n %}
<details data-filter-title="{{ title }}" open>
    <summary>
        {% blocktranslate with filter_title=title %} By {{ filter_title }} {% endblocktranslate %}
    </summary>
    <form method="get">
        <ul>
            <li>
                {% with params=choices|last %}
                    <input class="djal-selected-value" type="hidden" value="{{ params.selected_value|default_if_none:'' }}" />
                    <select
                      class="django-admin-list-filter-ajax"
                      data-ajax--cache="true"
                      data-ajax--delay="250"
                      data-ajax--type="GET"
                      data-ajax--url="{{ params.ajax_url }}"
                      data-placeholder="{{ _('All') }}"
                      data-allow-clear="true"
                      data-app-label="{{ params.app_label }}"
                      data-model-name="{{ params.model_name }}"
                      data-theme="admin-autocomplete"  <------- this line only
                      data-field-name="{{ params.field_name }}"></select>
                {% endwith %}
              </li>
          </ul>
      </form>
</details>
image

@vigo
Copy link
Owner

vigo commented Nov 7, 2024

@hongquan thank you

@vigo vigo merged commit 83e9385 into vigo:main Nov 7, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants