mirror of
https://github.com/Choices-js/Choices.git
synced 2024-05-11 10:06:35 +02:00
Amend copy
This commit is contained in:
parent
3886cbbd5c
commit
129d01c396
|
@ -281,7 +281,7 @@
|
|||
|
||||
<hr>
|
||||
<h2>Form interaction</h2>
|
||||
<p>Change the values and press reset (The select must be in a form element)</p>
|
||||
<p>Change the values and press reset to restore to initial state.</p>
|
||||
<form>
|
||||
<label for="reset-simple">Change me!</label>
|
||||
<select class="form-control" name="reset-simple" id="reset-simple" placeholder="Choose an option">
|
||||
|
|
|
@ -95,23 +95,22 @@ export default class Input {
|
|||
* @return
|
||||
*/
|
||||
setWidth(enforceWidth) {
|
||||
const callback = width => {
|
||||
this.element.style.width = width;
|
||||
};
|
||||
|
||||
if (this._placeholderValue) {
|
||||
// If there is a placeholder, we only want to set the width of the input when it is a greater
|
||||
// length than 75% of the placeholder. This stops the input jumping around.
|
||||
if (
|
||||
(this.element.value &&
|
||||
this.element.value.length >= this._placeholderValue.length / 1.25) ||
|
||||
enforceWidth
|
||||
) {
|
||||
this.calcWidth(width => {
|
||||
this.element.style.width = width;
|
||||
});
|
||||
const valueHasDesiredLength =
|
||||
this.element.value.length >= this._placeholderValue.length / 1.25;
|
||||
|
||||
if ((this.element.value && valueHasDesiredLength) || enforceWidth) {
|
||||
this.calcWidth(callback);
|
||||
}
|
||||
} else {
|
||||
// If there is no placeholder, resize input to contents
|
||||
this.calcWidth(width => {
|
||||
this.element.style.width = width;
|
||||
});
|
||||
this.calcWidth(callback);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue