Skip to content

Fix search box expanding width of container#5595

Merged
kevin-brown merged 1 commit into
developfrom
GH-5517
Jul 30, 2019
Merged

Fix search box expanding width of container#5595
kevin-brown merged 1 commit into
developfrom
GH-5517

Conversation

@kevin-brown

Copy link
Copy Markdown
Member

This pull request includes a

  • Bug fix
  • New feature
  • Translation

The following changes were made

  • The search box width is calculated using width instead of innerWidth

If this is related to an existing ticket, include a link to it as well.

Fixes #5517
Closes #5518

This fixes a bug with the search box where, when it had a placeholder,
it would expand the width of the selection container because it was
too large. This bug was specifically caused by the search box not
factoring in the padding surrounding it when caclualting the width
it needed to be, which resulted in the search box extending
outside of the selection container. This bug was easy to notice if
your Select2 was set to have 100% width and if the container it was
held within was not a block element.

This fixes the bug by switching to using `width()` for calculating
the search width instead of using `innerWidth()`, which ignored the
surrounding padding.

Fixes #5517
Closes #5518
@kevin-brown kevin-brown added this to the 4.0.9 milestone Jul 30, 2019
@kevin-brown kevin-brown merged commit f14bdf6 into develop Jul 30, 2019
@kevin-brown kevin-brown deleted the GH-5517 branch July 30, 2019 02:25
maxwellfet928 pushed a commit to maxwellfet928/select2 that referenced this pull request Jun 8, 2026
This fixes a bug with the search box where, when it had a placeholder,
it would expand the width of the selection container because it was
too large. This bug was specifically caused by the search box not
factoring in the padding surrounding it when caclualting the width
it needed to be, which resulted in the search box extending
outside of the selection container. This bug was easy to notice if
your Select2 was set to have 100% width and if the container it was
held within was not a block element.

This fixes the bug by switching to using `width()` for calculating
the search width instead of using `innerWidth()`, which ignored the
surrounding padding.

Fixes select2#5517
Closes select2#5518
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong width calculation of empty search input

2 participants