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

Refactor as custom select + Select2 4.1 compatibility #67

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

tagliala
Copy link
Contributor

@tagliala tagliala commented Mar 2, 2021

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

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 Styling is missing Disabled options  #60

Waiting for the proper branch to pushing against

Please help me testing

Screenshots

image

image

@tagliala
Copy link
Contributor Author

tagliala commented Mar 2, 2021

@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 tagliala force-pushed the feature/refactor-as-custom-select branch from d00a85e to 79d4f47 Compare March 2, 2021 17:57
@NordicAT
Copy link

NordicAT commented Mar 2, 2021

@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.

@tagliala
Copy link
Contributor Author

tagliala commented Mar 2, 2021

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

@NordicAT
Copy link

NordicAT commented Mar 2, 2021

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

Placeholder

@tagliala tagliala force-pushed the feature/refactor-as-custom-select branch from 79d4f47 to a4cf08d Compare March 2, 2021 19:24
@tagliala
Copy link
Contributor Author

tagliala commented Mar 2, 2021

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 tagliala force-pushed the feature/refactor-as-custom-select branch from a4cf08d to 8f13c45 Compare March 2, 2021 19:51
@tagliala
Copy link
Contributor Author

tagliala commented Mar 2, 2021

@NordicAT fixed, thanks

@tagliala tagliala changed the title Feature/refactor as custom select Refactor as custom select + Select2 4.1 compatibility Mar 2, 2021
@NordicAT
Copy link

NordicAT commented Mar 2, 2021

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

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 ...

@tagliala
Copy link
Contributor Author

tagliala commented Mar 2, 2021

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 tagliala force-pushed the feature/refactor-as-custom-select branch from 8f13c45 to 7a549ba Compare March 2, 2021 21:19
@tagliala
Copy link
Contributor Author

tagliala commented Mar 2, 2021

@NordicAT fixed both

@tagliala tagliala force-pushed the feature/refactor-as-custom-select branch from 7a549ba to df3c43e Compare March 2, 2021 21:45
@NordicAT
Copy link

NordicAT commented Mar 2, 2021

@tagliala
Wow - Thank you very much! ☺️
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/

@tagliala tagliala force-pushed the feature/refactor-as-custom-select branch from df3c43e to 3edb9df Compare March 2, 2021 22:09
@tagliala
Copy link
Contributor Author

tagliala commented Mar 2, 2021

@NordicAT done.

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

@tagliala tagliala force-pushed the feature/refactor-as-custom-select branch 3 times, most recently from c00bbfe to ffe389d Compare March 3, 2021 00:09
@NordicAT
Copy link

NordicAT commented Mar 3, 2021

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! ❤️ 👌
Hope there will be an official release soon ...

- Update jQuery to 3.6.0
- Fix Boostrap CSS to 4.6.0
- Update to Select2 4.1.rc0
- Add pre-selected examples
- Add default select fields
@tagliala tagliala force-pushed the feature/refactor-as-custom-select branch from 46f875b to 19d789a Compare March 14, 2021 16:07
- 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

Ref: https://getbootstrap.com/docs/4.6/components/forms/#select-menu

Close: ttskch#49, ttskch#60, ttskch#61, ttskch#19
@tagliala tagliala force-pushed the feature/refactor-as-custom-select branch from 19d789a to c848489 Compare March 14, 2021 16:11
Move styles inside theme
@tagliala
Copy link
Contributor Author

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

@Rikijs
Copy link

Rikijs commented Mar 19, 2021

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
Copy link

Rikijs commented Mar 19, 2021

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

@tagliala
Copy link
Contributor Author

This is not my repository, apologies

@yads
Copy link

yads commented Mar 19, 2021

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?

@Rikijs
Copy link

Rikijs commented Mar 20, 2021

I apologize for the negligence.

@NordicAT
Copy link

@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

@tagliala
Copy link
Contributor Author

This theme does not support Bootstrap 5

@NordicAT
Copy link

NordicAT commented Mar 20, 2021

@tagliala
I am sorry ✌️ - this was a mistake when adding the resources to the JSFiddle.
Here is the updated one with 4.6 CSS & JS: https://jsfiddle.net/5we3zL0t/

@tagliala
Copy link
Contributor Author

I've got the issue, but I don't know if 100% should be forced in the CSS

Please add width: $(this).data('width') ? $(this).data('width') : $(this).hasClass('w-100') ? '100%' : 'style', to the initializer

Ref: https://github.com/ttskch/select2-bootstrap4-theme/blob/master/docs/script.js#L5

@NordicAT
Copy link

NordicAT commented Mar 20, 2021

@tagliala
Working fine - Thank you very much! 👌

I have just realized that this may not be an issue for the end-user, because on page load it is displayed OK.

@Rikijs
Copy link

Rikijs commented Mar 26, 2021

@tagliala Could you please assess what is stil missing to finish this pull request?

@tagliala
Copy link
Contributor Author

@Rikijs since this is not backward compatible, it needs another branch on this repo to push against

@manuelmeurer
Copy link

@tagliala @ttskch What else is needed to get this merged/released? Can I help in any way?

@dwasyl
Copy link

dwasyl commented Jan 11, 2023

@tagliala Does this version still support 4.0.x as well, or only 4.1? (It does)

But, looking at the svg image used for the clear button, it seems to include a background image with an "X", whereas 4.0 includes an X in the text. Is there a reason for including the X in the svg (or how does one remove the default Select2 X)?

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.

Some css fixed
6 participants