1
1
import { matchEmoji , matchMention } from '../../utils/match.js' ;
2
2
import { emojiString } from '../emoji.js' ;
3
3
4
+ function userFriendlyScrollBehavior ( el ) {
5
+ // the TextExpander uses ComboboxNav, which uses scrollIntoView to scroll to the selected item.
6
+ // but their default behavior uses undefined (aka "start"), which annoys the end users a lot.
7
+ // if upstream could fix it, our code could be removed then. https://github.com/github/text-expander-element/issues/50
8
+ const oldScrollIntoView = el . scrollIntoView ;
9
+ el . scrollIntoView = function ( opts ) {
10
+ opts = opts || { block : 'nearest' , inline : 'nearest' } ;
11
+ oldScrollIntoView . call ( this , opts ) ;
12
+ } ;
13
+ }
14
+
4
15
export function initTextExpander ( expander ) {
5
16
expander ?. addEventListener ( 'text-expander-change' , ( { detail : { key, provide, text} } ) => {
6
17
if ( key === ':' ) {
@@ -15,6 +26,7 @@ export function initTextExpander(expander) {
15
26
li . setAttribute ( 'role' , 'option' ) ;
16
27
li . setAttribute ( 'data-value' , emoji ) ;
17
28
li . textContent = `${ emoji } ${ name } ` ;
29
+ userFriendlyScrollBehavior ( li ) ;
18
30
ul . append ( li ) ;
19
31
}
20
32
@@ -45,6 +57,7 @@ export function initTextExpander(expander) {
45
57
li . append ( fullnameSpan ) ;
46
58
}
47
59
60
+ userFriendlyScrollBehavior ( li ) ;
48
61
ul . append ( li ) ;
49
62
}
50
63
0 commit comments