select

Better select widgets in vanilla javascript.  https://p.ce9e.org/select/demo/
git clone https://git.ce9e.org/select.git

commit
2a7bb990d8b762a766ac82758a5ae196f911de97
parent
6b24f196a2deaaf5bd92a77e002e8d5285bffc47
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2023-08-09 04:13
fix: make sure values fit inside input

Diffstat

M values.js 5 +++++

1 files changed, 5 insertions, 0 deletions


diff --git a/values.js b/values.js

@@ -44,6 +44,10 @@ export class Values {
   44    44 			this.measure.style.font = style.font;
   45    45 			var text = this.measure.getBoundingClientRect();
   46    46 
   -1    47 			if (first.height > text.height) {
   -1    48 				this.input.style.lineHeight = `${first.height}px`;
   -1    49 			}
   -1    50 
   47    51 			if (width + this.gap + text.width < this.el.clientWidth) {
   48    52 				this.input.style.paddingTop = `${paddingTop + height}px`;
   49    53 				this.input.style.textIndent = `${width + this.gap}px`;
@@ -54,6 +58,7 @@ export class Values {
   54    58 		} else {
   55    59 			this.input.style.paddingTop = `${paddingTop}px`;
   56    60 			this.input.style.textIndent = '0';
   -1    61 			this.input.style.lineHeight = null;
   57    62 		}
   58    63 	}
   59    64