mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 05:37:34 +03: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:
parent
1640901114
commit
b703ddd703
@ -258,7 +258,19 @@ const Form = (props) => {
|
|||||||
return;
|
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();
|
editor?.commands.focus();
|
||||||
window.scrollTo({
|
window.scrollTo({
|
||||||
top: getScrollToPosition(),
|
top: getScrollToPosition(),
|
||||||
|
Loading…
Reference in New Issue
Block a user