File tree Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,8 @@ const NodeMenu = ({
100100
101101 const keydownListener = useCallback (
102102 ( e : KeyboardEvent ) => {
103+ if ( e . metaKey || e . ctrlKey || e . shiftKey ) return ;
104+
103105 if ( e . key === "ArrowDown" ) {
104106 const index = Number (
105107 menuRef . current ?. getAttribute ( "data-active-index" ) ,
Original file line number Diff line number Diff line change @@ -257,7 +257,10 @@ export const initObservers = async ({
257257
258258 const selection = window . getSelection ( ) ;
259259
260- if ( ! selection || selection . rangeCount === 0 ) return ;
260+ if ( ! selection || selection . rangeCount === 0 || ! selection . focusNode ) {
261+ removeTextSelectionPopup ( ) ;
262+ return ;
263+ }
261264
262265 const selectedText = selection . toString ( ) . trim ( ) ;
263266
Original file line number Diff line number Diff line change @@ -65,9 +65,9 @@ export const renderTextSelectionPopup = ({
6565} ;
6666
6767export const removeTextSelectionPopup = ( ) => {
68- if ( currentPopupContainer ) {
69- ReactDOM . unmountComponentAtNode ( currentPopupContainer ) ;
70- currentPopupContainer . remove ( ) ;
71- currentPopupContainer = null ;
68+ const container = document . getElementById ( "discourse-text-selection-popup" ) ;
69+ if ( container ) {
70+ ReactDOM . unmountComponentAtNode ( container ) ;
71+ container . remove ( ) ;
7272 }
7373} ;
You can’t perform that action at this time.
0 commit comments