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

Control input retains placeholder width after placeholder is cleared #384

Closed
adamlogic opened this issue Apr 17, 2014 · 3 comments
Closed

Comments

@adamlogic
Copy link

The control input width is initially set using the width of the placeholder text. This is expected, but once the control gets focus and the placeholder is cleared, the width should shrink. The consequence of this is that when the control input is too wide, it is pushed down to the next line.

Best explained with a gif:

selectize-bug

Here is the CodePen used to produce this bug.

@adamlogic adamlogic changed the title Control input retains placeholder with after placeholder is cleared Control input retains placeholder width after placeholder is cleared Apr 17, 2014
@adamlogic
Copy link
Author

This is the line which prevents the control input from updating its width (growing) after the placeholder is cleared:

self.$control_input.data('grow', !isFull && !isLocked);

Removing that line fixes the bug for me. It was introduced in 95770a4 to "Allow caret movement when control is full". Caret movement seems to work fine for me without that line, so I'm not really sure of its purpose.

@brianreavis
Copy link
Member

Issues that come with GIFs are the best. Makes it so easy to see what's going on!

The autogrowing is really proactive about adjusting the size of the textbox. It'll resize on keydown, before the typed character is even in the box. This is to prevent weird moving text – the space for the added character will be available before the browser goes to add the character. When Selectize is in multiple-select mode, disabling the growing is especially important. If it's full, and the caret's between items, items will shift around even though no characters end up in the textbox. That's why it's not safe to remove that line.

Just patched up the problem! Thanks man :)

@adamlogic
Copy link
Author

Great! Thanks for the fix, and for the explanation.

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

No branches or pull requests

2 participants