select2-bootstrap4-theme icon indicating copy to clipboard operation
select2-bootstrap4-theme copied to clipboard

Refactor as custom select + Select2 4.1 compatibility

Open tagliala opened this issue 3 years ago • 37 comments

Close: #19, #49, #51, #60, #61

  • Add compatibility with Select2 4.1
  • Uses Bootstrap's custom-select implementation for uniformity
  • Use SVG background image for clear button
  • Add some lints to improve code readability
  • Use the same Browserlist configuration as Bootstrap 4.6
  • Add SCSS variables for easier customization #51
  • Add support for feedback validation icons

Fixes the following existing issues:

  • Missing input focus in single select dropdown
  • Fix input color in single select dropdown
  • Fix cursor pointer when hovering on search input in disabled select
  • Fix disabled color #60

Waiting for the proper branch to pushing against

Please help me testing

Screenshots

image

image

tagliala avatar Mar 02 '21 16:03 tagliala

@tagliala I have tested your reimplementation. I like it, but there seems to be a bug with an empty multiselect. Have a look at the following screenshot:

Select2-Multiselect

tagliala avatar Mar 02 '21 17:03 tagliala

@tagliala I just figured out the issue. I am sorry - It does not have anything to do with your code/css.

I had a custom-fix for an issue in my CSS, which is described here: Placeholder being cut off?

This is hopefully not necessary anymore. After removing this, the reported issue disappeared of course.

I am sorry and thank you for the support.

NordicAT avatar Mar 02 '21 18:03 NordicAT

Hi @NordicAT, don't worry, you're welcome.

Hi. I think this is a known issue since 2012 when select2 with multiselect is initialized inside a hidden element.

I can try how to replicate, but maybe this has been fixed upstream in select2 4.1

tagliala avatar Mar 02 '21 18:03 tagliala

May it be the case, that the font-family of the placeholder-text differs from a Single-Select to a Multi-Select?

Placeholder

NordicAT avatar Mar 02 '21 18:03 NordicAT

I can confirm an issue with font-family. It is being stripped out from the dist css and I should fix a rule. I'm investigating

tagliala avatar Mar 02 '21 19:03 tagliala

@NordicAT fixed, thanks

tagliala avatar Mar 02 '21 19:03 tagliala

I can confirm, that the font-family issue is fixed with the latest CSS - Thank you! :thumbsup:

I believe there is something wrong with Multi-Select.

The screenshot below shows a Multi-Select from the original Select2-docs:

Select2

Items that have been already selected have a grey background in the list.

First issue:

When looking on the same situation with your/our CSS for BS4 the background is way too light in my opinion. It may be, that my monitor has too less contrast, but I can hardly see a difference between selected and not selected items:

Select2-BS4

It must not be as dark as in the original Select2 CSS.

Second issue:

As in the screenshot above I see a light-grey background on selected items in the list. If I hoover over those items using the mouse-cursor, they lose their light-grey background. I have to reopen the list to bring it back.

I hope this issues are not in my environment only ...

NordicAT avatar Mar 02 '21 20:03 NordicAT

When looking on the same situation with your/our CSS for BS4 the background is way too light in my opinion

Agreed. Let me check how bootstrap deals with this. edit: I've just used ~10% darken background~ the disabled color bg

As in the screenshot above I see a light-grey background on selected items in the list.

Replicated. It is also an issue at https://ttskch.github.io/select2-bootstrap4-theme/

tagliala avatar Mar 02 '21 20:03 tagliala

@NordicAT fixed both

tagliala avatar Mar 02 '21 21:03 tagliala

@tagliala Wow - Thank you very much! :relaxed: I can confirm that both issues are fixed.

Just a small cosmetic one:

When activating a Multi-Select by clicking on it, the select-box gets a blue outer-glow:

Multi-Select

When activating a Single-Select by clicking on it, the select-box does not get a blue outer-glow.

Single-Select

It gets glowing after an item has been selected.

I may be wrong, but for me this does not seem consistent. Looking at the Bootstrap-Docs the Select is glowing when activating: https://getbootstrap.com/docs/4.6/components/forms/

NordicAT avatar Mar 02 '21 21:03 NordicAT

@NordicAT done.

I've added the focus style to the properly focused input element, as in the default Select2

tagliala avatar Mar 02 '21 22:03 tagliala

I just use basic features of Select2 and for me it is working fine now. There is nothing to complain about.

Thank you very much for your effort! :heart: :ok_hand: Hope there will be an official release soon ...

NordicAT avatar Mar 03 '21 06:03 NordicAT

Hi!

Thanks for updating Select2 Bootsrtap4 Theme!

Does updated (in development) select2-bootstrap4-theme theme is compatible with form validation with jQuery validation updated (Bootstrap v4.6 custom select) design?

I guess it should, but want to be on the safe side. (Did not see any examples in your screenshots).

Probably - with single select - it should be ok. Yet on multiple select close button may conflict with satus (valid/invalid field) icon.

Rikijs avatar Mar 03 '21 20:03 Rikijs

Does updated (in development) select2-bootstrap4-theme theme is compatible with form validation with jQuery validation updated (Bootstrap v4.6 custom select) design?

  • Is the previous version of this theme compatible with that plugin?
  • Is Select2 4.1 rc0 with the default theme compatible with that plugin?

If the answer is yes to both, could you please create a fiddle and check that this update didn't break things?

tagliala avatar Mar 03 '21 20:03 tagliala

1

Is the previous version of this theme compatible with that plugin?

I think it is partly compatible (when validating border is green/red but no success/error icon is displayed)

2

Is Select2 4.1 rc0 with the default theme compatible with that plugin?

Sadly, i can not find info about support of jQuery validation with Select2 v4. Issues on GItHub with this keyword seem to be 5 years old and reference older version of Select2.

3 As this issue reads "Refactor as custom select + Select2 4.1 compatibility" i hope that changes to markup (based on Bootstrap v4.6 custom-select) allows to display icons indicating validations success/fail icons additionally to field border.

Rikijs avatar Mar 03 '21 21:03 Rikijs

As this issue reads "Refactor as custom select + Select2 4.1 compatibility" i hope that changes to markup (based on Bootstrap v4.6 custom-select) allows to display icons indicating validations success/fail icons additionally to field border.

I can fix this

tagliala avatar Mar 03 '21 21:03 tagliala

@Rikijs

image

with focus:

image

Will add custom variables and commit

tagliala avatar Mar 03 '21 21:03 tagliala

Looks good! Perhaps, there should be a litte more spacing between field clear icon and validation status success/error icon.

Rikijs avatar Mar 03 '21 21:03 Rikijs

@Rikijs done

tagliala avatar Mar 03 '21 22:03 tagliala

Great! Just a litle typo in updated image of different states. It is saying "Invalid example" 2 times.

Rikijs avatar Mar 04 '21 10:03 Rikijs

Question: Is it currently posible to change color of all select2 borders in one go in one place? Default is too light for my current project and overriding seams to be planed in this isssue. Yet overriding in CSS (using 1.5.2 version) overrides success/error states. (I might be overriding not efficiently.) Variables file would be preferable solution.

Rikijs avatar Mar 04 '21 11:03 Rikijs

Question: Is it currently posible to change color of all select2 borders in one go in one place?

The only variable used for border color should be $select2-bootstrap4-border-color. Danger and Success are inherited from bootstrap

Yet overriding in CSS (using 1.5.2 version) overrides success/error states. (I might be overriding not efficiently.)

If you need to override via CSS, you should preserve the order of rules and css specificity

tagliala avatar Mar 04 '21 12:03 tagliala

I've fixed a couple of issues with validation focus and validation icons are now supported also in select multiple

tagliala avatar Mar 14 '21 17:03 tagliala

I've fixed a couple of issues with validation focus and validation icons are now supported also in select multiple

That is great news!

Rikijs avatar Mar 19 '21 19:03 Rikijs

@tagliala please share your estimate when release/tag could be made?

Rikijs avatar Mar 19 '21 19:03 Rikijs

This is not my repository, apologies

tagliala avatar Mar 19 '21 19:03 tagliala

I've been using your branch @tagliala and following this PR for changes. Appreciate the work! Have you considered publishing your changes to npm under @tagliala/select2-bootstrap4-theme?

yads avatar Mar 19 '21 19:03 yads

I apologize for the negligence.

Rikijs avatar Mar 20 '21 12:03 Rikijs

@tagliala

Hi, I was trying to create a Bootstrap Horizontal form with Select2 selects.
It looks like this:

HorizontalForm

There seems to be a problem in Smartphone-size:

HorizontalForm-SM

I have created the following JSFiddle using a strapped-down sample-code to reproduce the issue: https://jsfiddle.net/612pmajt/3/

I am not sure about the problem-source. It may not be the fault of the select2-bootstrap4-theme. I can't exclude my own code. Could you please have a short look?

Thank you

NordicAT avatar Mar 20 '21 14:03 NordicAT

This theme does not support Bootstrap 5

tagliala avatar Mar 20 '21 15:03 tagliala