better-yt-shorts icon indicating copy to clipboard operation
better-yt-shorts copied to clipboard

just a tip

Open VladyslavKvaskov opened this issue 2 months ago • 0 comments

https://github.com/ynshung/better-yt-shorts/blame/c3c039b4e868d2330c653fdd6105d7c93d607e87/src/lib/handleKeyEvent.ts#L21-L29 image

This logic looks weird. Just check if the actual activeElement is an input or has the attribute "contenteditable". No need to get all the inputs and contenteditable elements to check if they contain the activeElement.

if (
     document.activeElement && 
    (document.activeElement.tagName.toLowerCase() === 'input' || document.activeElement.hasAttribute('contenteditable'))
)

return;

VladyslavKvaskov avatar Apr 13 '24 23:04 VladyslavKvaskov