This repository was archived by the owner on May 8, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +19
-23
lines changed
Expand file tree Collapse file tree 1 file changed +19
-23
lines changed Original file line number Diff line number Diff line change 1919 const { TypeaheadEditor, normalizeSelectedIndex } = DraftTypeahead ;
2020
2121 const people = [
22- {
23- name : 'Justin Vaillancourt' ,
24- img : ''
25- } ,
26- {
27- name : 'Ellie Pritts' ,
28- img : ''
29- } ,
30- {
31- name : 'Maxime Santerre' ,
32- img : ''
33- } ,
34- {
35- name : 'Melody Ma' ,
36- img : ''
37- } ,
38- {
39- name : 'Kris Hartvigsen' ,
40- img : ''
41- }
22+ 'Justin Vaillancourt' ,
23+ 'Ellie Pritts' ,
24+ 'Maxime Santerre' ,
25+ 'Melody Ma' ,
26+ 'Kris Hartvigsen'
4227 ] ;
4328
4429 const Mentions = ( { left, top, selectedIndex, text } ) => {
4732 left,
4833 top
4934 } ) ;
50- const normalizedIndex = normalizeSelectedIndex ( selectedIndex , people . length ) ;
35+
36+ const relevantPeople = people . filter ( person => {
37+ const query = text . toLowerCase ( ) . replace ( / ^ @ / , '' ) ;
38+ return person . toLowerCase ( ) . startsWith ( query ) ;
39+ } ) ;
40+ if ( ! relevantPeople ) {
41+ return null ;
42+ }
43+
44+ const normalizedIndex = normalizeSelectedIndex (
45+ selectedIndex , relevantPeople . length
46+ ) ;
5147 return (
5248 < ul style = { typeaheadStyle } >
53- { people . map ( ( person , index ) => {
49+ { relevantPeople . map ( ( person , index ) => {
5450 const style =
5551 index === normalizedIndex ?
5652 styles . selectedPerson : styles . person ;
5753 return (
5854 < li style = { style } >
59- { person . name }
55+ { person }
6056 </ li >
6157 ) ;
6258 } ) }
You can’t perform that action at this time.
0 commit comments