bonafideduck / react-highlight-within-textarea

React component for highlighting bits of text within a textarea
100 stars 13 forks source link

Selection on highlighted word on single click. #165

Open djwondersco opened 2 years ago

djwondersco commented 2 years ago

Is selecting on highlighted word on singlie click possible? I've tried but the highlighted text rerenders every click, therefore the word gets unselected.

bonafideduck commented 2 years ago

There isn’t any built-in support for this. Also note that “highlight” != selection. Highlight is simply decorating parts of the code. Selection is combination of focus and anchor. There is an interface to set the selection, though. Search for selection in https://bonafideduck.github.io/react-highlight-within-textarea/#selection.