mirror of https://github.com/vector-im/riot-web
				
				
				
			Fix input field behaviour inside context menus (#7293)
							parent
							
								
									275e9c1d02
								
							
						
					
					
						commit
						2e4fe7891a
					
				| 
						 | 
					@ -25,6 +25,7 @@ import { Key } from "../../Keyboard";
 | 
				
			||||||
import { Writeable } from "../../@types/common";
 | 
					import { Writeable } from "../../@types/common";
 | 
				
			||||||
import { replaceableComponent } from "../../utils/replaceableComponent";
 | 
					import { replaceableComponent } from "../../utils/replaceableComponent";
 | 
				
			||||||
import UIStore from "../../stores/UIStore";
 | 
					import UIStore from "../../stores/UIStore";
 | 
				
			||||||
 | 
					import { getInputableElement } from "./LoggedInView";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Shamelessly ripped off Modal.js.  There's probably a better way
 | 
					// Shamelessly ripped off Modal.js.  There's probably a better way
 | 
				
			||||||
// of doing reusable widgets like dialog boxes & menus where we go and
 | 
					// of doing reusable widgets like dialog boxes & menus where we go and
 | 
				
			||||||
| 
						 | 
					@ -248,6 +249,9 @@ export default class ContextMenu extends React.PureComponent<IProps, IState> {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // only handle escape when in an input field
 | 
				
			||||||
 | 
					        if (ev.key !== Key.ESCAPE && getInputableElement(ev.target as HTMLElement)) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let handled = true;
 | 
					        let handled = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        switch (ev.key) {
 | 
					        switch (ev.key) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -73,7 +73,7 @@ import LegacyCommunityPreview from "./LegacyCommunityPreview";
 | 
				
			||||||
// NB. this is just for server notices rather than pinned messages in general.
 | 
					// NB. this is just for server notices rather than pinned messages in general.
 | 
				
			||||||
const MAX_PINNED_NOTICES_PER_ROOM = 2;
 | 
					const MAX_PINNED_NOTICES_PER_ROOM = 2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function getInputableElement(el: HTMLElement): HTMLElement | null {
 | 
					export function getInputableElement(el: HTMLElement): HTMLElement | null {
 | 
				
			||||||
    return el.closest("input, textarea, select, [contenteditable=true]");
 | 
					    return el.closest("input, textarea, select, [contenteditable=true]");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue