Skip to content

Commit

Permalink
feat: support Shadow DOM
Browse files Browse the repository at this point in the history
  • Loading branch information
twrichards committed Oct 7, 2021
1 parent 9825902 commit 7a302ef
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Textarea.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -738,14 +738,22 @@ class ReactTextareaAutocomplete extends React.Component<
this.textareaRef.dispatchEvent(event);
}

const textarea = event.target;
const textarea = event.target || this.textareaRef; // fallback to support Shadow DOM
const { selectionEnd } = textarea;
const value = textarea.value;
this.lastValueBubbledEvent = value;

if (onChange && event) {
event.persist && event.persist();
onChange(event);

onChange(new Proxy(event, {
get(original, prop, receiver) {
if(prop === "target"){
return textarea;
}
return Reflect.get(original, prop, receiver);
}
}));
}

if (onCaretPositionChange) {
Expand Down

0 comments on commit 7a302ef

Please sign in to comment.