Skip to content

Conversation

@dhotson
Copy link
Contributor

@dhotson dhotson commented Jul 26, 2024

Hi there!

I had a small problem when using a filter with multiple selection turned on

   filter :role_in, as: :select, multiple: true

It currently looks like this:

image

As you can see, the <select multiple> element is getting a white background with white text when in dark mode.

The rule in plugin.js is supposed to kick in and apply some tailwind styles to make things look good in dark mode i.e.

      [['[type=date]', '[type=email]', '[type=number]', '[type=password]', '[type=tel]', '[type=text]', '[type=time]', '[type=url]', 'select', 'textarea']]: {
        '@apply bg-gray-50 border border-gray-300 text-gray-900 rounded-md focus:ring-blue-500 focus:border-blue-500 w-full dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500': {}

.. but the specificity of the base input styles near the top of plugin.js is getting in the way of applying dark:bg-gray-700 properly. It's stuck with background-color: #fff.

It looks like it is a CSS specificity issue because the rule matches both the select and [multiple] rules.

This PR removes the [multiple] selector on the base input style.. I think it should already be covered by the select selector?

Thanks!

I had a problem where a <select multiple> element was getting
a white background with white text when in dark mode.

It looks like it was a CSS specificity issue because the rule matches
both the `select` and `[multiple]` rules.

The rule further down is supposed to kick in i.e.
```
      [['[type=date]', '[type=email]', '[type=number]', '[type=password]', '[type=tel]', '[type=text]', '[type=time]', '[type=url]', 'select', 'textarea']]: {
        '@apply bg-gray-50 border border-gray-300 text-gray-900 rounded-md focus:ring-blue-500 focus:border-blue-500 w-full dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500': {}
```

.. but the specificity of the base CSS rule was getting in the way of applying `dark:bg-gray-700`
@codecov
Copy link

codecov bot commented Jul 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.10%. Comparing base (dae308d) to head (f4a7610).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #8406   +/-   ##
=======================================
  Coverage   99.10%   99.10%           
=======================================
  Files         140      140           
  Lines        4018     4018           
=======================================
  Hits         3982     3982           
  Misses         36       36           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@javierjulio javierjulio changed the title Fix style for multiple select filters Fix styles for select[multiple] form controls Jul 27, 2024
@javierjulio javierjulio self-assigned this Jul 27, 2024
@javierjulio javierjulio self-requested a review July 27, 2024 16:33
Copy link
Member

@javierjulio javierjulio left a comment

Choose a reason for hiding this comment

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

Thanks! I still need to update the dark mode styles for form controls as it's using an older set of colors (from Flowbite example) that I didn't think was good enough when comparing to other dark mode implementations. If you use dark mode a lot I'd appreciate any help or improvements there.

@javierjulio javierjulio merged commit ed6f904 into activeadmin:master Jul 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants