Skip to content

Commit

Permalink
chore: refine the target event
Browse files Browse the repository at this point in the history
Signed-off-by: dominictb <[email protected]>
  • Loading branch information
dominictb committed Jun 12, 2024
1 parent 0dee608 commit 6728e0c
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions src/hooks/useHtmlPaste/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,10 @@ const useHtmlPaste: UseHtmlPaste = (textInputRef, preHtmlPasteCallback, removeLi
// Pointer will go out of sight when a large paragraph is pasted on the web. Refocusing the input keeps the cursor in view.
// to avoid the keyboard in mobile web if using blur() and focus() function, we just need to dispatch the event to trigger the onFocus handler

textInputHTMLElement.dispatchEvent(
new FocusEvent('focus', {
bubbles: true,
cancelable: true,
view: window,
}),
);

// need to trigger the focusin event to make sure the onFocus handler is triggered
// need to trigger the bubbled "focusin" event to make sure the onFocus handler is triggered
textInputHTMLElement.dispatchEvent(
new FocusEvent('focusin', {
bubbles: true,
cancelable: true,
view: window,
}),
);
// eslint-disable-next-line no-empty
Expand Down

0 comments on commit 6728e0c

Please sign in to comment.