Skip to content

Conversation

bews
Copy link

@bews bews commented May 8, 2017

This pull request includes a

  • Bug fix
  • New feature
  • Translation

Fixes #291, #3669 and other duplicates.

@jpic
Copy link
Contributor

jpic commented May 27, 2017

The width change makes sense but is there any risk that the closest call fails to pick the right element ?

If both this.$search and its .select2-search--inline are children of the widget's parent element then it would be safe.

I wonder what @kevin-brown meant in the comment that there is no clean fix here #3669 (comment)

@bews
Copy link
Author

bews commented Jun 21, 2017

I didn't look deep into the code, but I believe .select2-search--inline is always there. And it's the direct parent of this.$search.

}

this.$search.css('width', width);
this.$search.closest('.select2-search--inline').css('width', widthParent);
Copy link
Author

Choose a reason for hiding this comment

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

This can be replaced by .parent() to be sure.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you still want to make that change?

Copy link
Author

Choose a reason for hiding this comment

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

It works fine the way it is, but I can change it if you think .parent() is a better approach. I'm ok with either.

@cssagogo
Copy link

When is this fix going out?

@alexweissman
Copy link
Contributor

alexweissman commented Oct 20, 2017

It just seems suspicious to me that replacing a calculated value like width = this.$selection.find('.select2-selection__rendered').innerWidth(); with a hardcoded value like 100% would be a fix.

Surely there must be a reason that it wasn't set to 100% in the first place?

By the way, a more conservative patch is suggested in #3292:

width = this.$selection.find('.select2-selection__rendered').innerWidth() || '100%';

I'd be more comfortable merging this, if I understood why it was calculated the way it is, in the first place.

@bews
Copy link
Author

bews commented Oct 21, 2017

width = this.$selection.find('.select2-selection__rendered').innerWidth() || '100%';

This doesn't work, since innerWidth returns incorrect value, not 0. It may be bigger than it should, or a fixed 100px.

I dunno why it returns that and don't have time to figure out.

@xander-mu
Copy link

this css works perfect for me (multiple selection, select starts hidden):

.select2-container .select2-selection__rendered > *:first-child.select2-search--inline {
width: 100% !important;
}
.select2-container .select2-selection__rendered > *:first-child.select2-search--inline .select2-search__field {
width: 100% !important;
}

@vpn
Copy link

vpn commented Jul 28, 2018

Thanks for that, @ala-musleh.

@stale
Copy link

stale bot commented Mar 13, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the status: stale label Mar 13, 2019
@stale stale bot closed this Mar 20, 2019
LeSuisse added a commit to Enalean/tuleap that referenced this pull request Nov 27, 2019
The issue is due to a select2 issue [0][1][2][3][4], a
workaround that seem good enough for our context has been applied.

Part of story #14190: get email notifications on pull requests - first stage

[0] select2/select2#4323
[1] select2/select2#291
[2] select2/select2#4898
[3] select2/select2#3817
[4] select2/select2#4776

Change-Id: I2ae52204a41451b74ce40100588eac7ccca9823e
thinkh added a commit to datavisyn/tdp_core that referenced this pull request Jun 22, 2020
@spo0okie
Copy link

this problem stil exists on visible elements (not only for hidden ones from closed issues) for multiple select, and that fix works perfect. why it sitll not merged?

spo0okie added a commit to spo0okie/select2 that referenced this pull request May 5, 2024
@seaexplorer2024
Copy link

just commenting I still get the same issue on V4.0.13 for multi selects.

Using @xander-mu's styling has fixed it for me

@DonSYS91
Copy link

Issue still exists as of now as well on latest version.
Thank you so much @xander-mu for the workaround

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.

9 participants