select

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

commit
b65945c15cefbdb65b48576b7057af3db46d6c55
parent
f55ded9fd008805cec9b0a245c8b2ad121dd502a
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2021-05-28 11:59
improve mouse handling on dropdown

inspired by https://github.com/LeaVerou/awesomplete/

Diffstat

M select.js 10 ++++++----

1 files changed, 6 insertions, 4 deletions


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

@@ -68,6 +68,12 @@ export class Select {
   68    68 			}
   69    69 		};
   70    70 
   -1    71 		// Prevent blurring input. This also ensures dragging the cursor away from
   -1    72 		// the list item will cancel the selection
   -1    73 		this.dropdown.onmousedown = event => {
   -1    74 			event.preventDefault();
   -1    75 		};
   -1    76 
   71    77 		this.updateValue();
   72    78 	}
   73    79 
@@ -244,10 +250,6 @@ export class Select {
  244   250 	}
  245   251 
  246   252 	onblur(event) {
  247    -1 		if (event.relatedTarget === this.dropdown) {
  248    -1 			return;
  249    -1 		}
  250    -1 
  251   253 		if (!this.input.value) {
  252   254 			if (!this.original.multiple) {
  253   255 				this.original.value = '';