File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed
src/components/AutoCompleteTextarea Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -10,13 +10,15 @@ const List = (props) => {
1010 const {
1111 className,
1212 component,
13+ currentTrigger,
1314 dropdownScroll,
1415 getSelectedItem,
1516 getTextToReplace,
1617 itemClassName,
1718 itemStyle,
1819 onSelect,
1920 style,
21+ selectionEnd,
2022 SuggestionItem = Item ,
2123 value : propValue ,
2224 values,
@@ -123,7 +125,10 @@ const List = (props) => {
123125 const restructureItem = ( item ) => {
124126 const matched = item . name || item . id ;
125127
126- const editedPropValue = escapeRegExp ( propValue . slice ( 1 ) ) ;
128+ const textBeforeCursor = propValue . slice ( 0 , selectionEnd ) ;
129+ const triggerIndex = textBeforeCursor . lastIndexOf ( currentTrigger ) ;
130+ const editedPropValue = escapeRegExp ( textBeforeCursor . slice ( triggerIndex + 1 ) ) ;
131+
127132 const parts = matched . split ( new RegExp ( `(${ editedPropValue } )` , 'gi' ) ) ;
128133
129134 const itemNameParts = { match : editedPropValue , parts } ;
Original file line number Diff line number Diff line change @@ -635,12 +635,14 @@ class ReactTextareaAutocomplete extends React.Component {
635635 < SuggestionList
636636 className = { listClassName }
637637 component = { component }
638+ currentTrigger = { currentTrigger }
638639 dropdownScroll = { this . _dropdownScroll }
639640 getSelectedItem = { selectedItem }
640641 getTextToReplace = { textToReplace }
641642 itemClassName = { itemClassName }
642643 itemStyle = { itemStyle }
643644 onSelect = { this . _onSelect }
645+ selectionEnd = { this . state . selectionEnd }
644646 SuggestionItem = { SuggestionItem }
645647 value = { value }
646648 values = { suggestionData }
You can’t perform that action at this time.
0 commit comments