File tree 3 files changed +50
-13
lines changed
3 files changed +50
-13
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " geist-ui-svelte" ,
3
- "version" : " 0.7.6 " ,
3
+ "version" : " 0.7.7 " ,
4
4
"author" : {
5
5
"name" : " Aidan Bleser" ,
6
6
"url" : " https://aidanbleser.com"
354
354
"@fontsource/geist-mono" : " ^5.0.3" ,
355
355
"@fontsource/geist-sans" : " ^5.0.3" ,
356
356
"@sveltejs/kit" : " ^2.5.10" ,
357
- "@vercel/analytics" : " ^1.3.0 " ,
358
- "@vercel/speed-insights" : " ^1.0.10 " ,
357
+ "@vercel/analytics" : " ^1.3.1 " ,
358
+ "@vercel/speed-insights" : " ^1.0.11 " ,
359
359
"autoprefixer" : " ^10.4.19" ,
360
360
"class-variance-authority" : " ^0.7.0" ,
361
361
"clsx" : " ^2.1.1" ,
Original file line number Diff line number Diff line change 278
278
e .preventDefault ();
279
279
searchEnter ();
280
280
}
281
+
282
+ if (show && / ^ [a-zA-Z ] {1,1} $ / .test (e .key )) {
283
+ findByCharacter (e .key );
284
+ }
285
+ };
286
+
287
+ const findByCharacter = (char : string ) => {
288
+ const options = Array .from (dropDownRef .children );
289
+
290
+ let hasSelected = false ;
291
+
292
+ for (let i = 0 ; i < options .length ; i ++ ) {
293
+ const option = options [i ] as HTMLElement ;
294
+ if (option .tagName == " BUTTON" && option .hasAttribute (" data-value" )) {
295
+ const child = findChild (option , (a ) =>
296
+ a .hasAttribute (" data-html" ),
297
+ ) as HTMLDivElement ;
298
+ if (child .innerText [0 ].toLowerCase () == char .toLowerCase () && ! hasSelected ) {
299
+ selectedIndex = i ;
300
+ hasSelected = true ;
301
+ option .setAttribute (" data-focused" , " true" );
302
+ const top = dropDownRef .offsetHeight + dropDownRef .scrollTop ;
303
+ const elementBottom = option .offsetHeight + option .offsetTop ;
304
+ if (top < elementBottom ) {
305
+ const scrollTop = elementBottom + 8 - dropDownRef .offsetHeight ;
306
+ dropDownRef .scrollTop = scrollTop ;
307
+ }
308
+
309
+ if (top - option .offsetTop + 110 > dropDownRef .offsetHeight ) {
310
+ const scrollTop = option .offsetTop - dropDownRef .offsetHeight / 2 ;
311
+ dropDownRef .scrollTop = scrollTop ;
312
+ }
313
+ } else {
314
+ option .setAttribute (" data-focused" , " false" );
315
+ }
316
+ }
317
+ }
281
318
};
282
319
283
320
let selectedIndex = 0 ;
You can’t perform that action at this time.
0 commit comments