2
1
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2023-12-13 21:00:40 +01:00

Fixed C keyboard shortcut when input is focused

fixes https://github.com/TryGhost/Team/issues/1767

- Only focus the form if there is no other input focused on the page
This commit is contained in:
Simon Backx 2022-08-10 15:41:57 +02:00
parent 1640901114
commit b703ddd703

View file

@ -258,7 +258,19 @@ const Form = (props) => {
return;
}
if (event.key === 'c' && !props.isEdit && !props.isReply && !editor?.isFocused) {
let focusedElement = document.activeElement;
while (focusedElement && focusedElement.tagName === 'IFRAME') {
if (!focusedElement.contentDocument) {
// CORS issue
// disable the C shortcut when we have a focused external iframe
break;
}
focusedElement = focusedElement.contentDocument.activeElement;
}
const hasInputFocused = focusedElement && (focusedElement.tagName === 'INPUT' || focusedElement.tagName === 'TEXTAREA' || focusedElement.tagName === 'IFRAME' || focusedElement.contentEditable === 'true');
if (event.key === 'c' && !props.isEdit && !props.isReply && !editor?.isFocused && !hasInputFocused) {
editor?.commands.focus();
window.scrollTo({
top: getScrollToPosition(),