Restores ESC to close preferences
This commit is contained in:
parent
424d8785b6
commit
c304cb84fe
3 changed files with 21 additions and 1 deletions
|
@ -101,8 +101,9 @@ const createProps = (): PropsType => ({
|
|||
zoomFactor: 1,
|
||||
|
||||
addCustomColor: action('addCustomColor'),
|
||||
editCustomColor: action('editCustomColor'),
|
||||
closeSettings: action('closeSettings'),
|
||||
doDeleteAllData: action('doDeleteAllData'),
|
||||
editCustomColor: action('editCustomColor'),
|
||||
getConversationsWithCustomColor: () => Promise.resolve([]),
|
||||
initialSpellCheckSetting: true,
|
||||
makeSyncRequest: () => {
|
||||
|
|
|
@ -76,6 +76,7 @@ export type PropsType = {
|
|||
|
||||
// Other props
|
||||
addCustomColor: (color: CustomColorType) => unknown;
|
||||
closeSettings: () => unknown;
|
||||
doDeleteAllData: () => unknown;
|
||||
editCustomColor: (colorId: string, color: CustomColorType) => unknown;
|
||||
getConversationsWithCustomColor: (
|
||||
|
@ -158,6 +159,7 @@ export const Preferences = ({
|
|||
availableMicrophones,
|
||||
availableSpeakers,
|
||||
blockedCount,
|
||||
closeSettings,
|
||||
customColors,
|
||||
defaultConversationColor,
|
||||
deviceName = '',
|
||||
|
@ -249,6 +251,22 @@ export const Preferences = ({
|
|||
document.body.classList.toggle('dark-theme', theme === ThemeType.dark);
|
||||
}, [theme]);
|
||||
|
||||
useEffect(() => {
|
||||
const handler = (event: KeyboardEvent) => {
|
||||
if (event.key === 'Escape') {
|
||||
closeSettings();
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
};
|
||||
document.addEventListener('keydown', handler);
|
||||
|
||||
return () => {
|
||||
document.removeEventListener('keydown', handler);
|
||||
};
|
||||
}, [closeSettings]);
|
||||
|
||||
const onZoomSelectChange = useCallback(
|
||||
(value: string) => {
|
||||
const number = parseFloat(value);
|
||||
|
|
|
@ -291,6 +291,7 @@ async function renderPreferences() {
|
|||
|
||||
// Actions and other props
|
||||
addCustomColor: ipcAddCustomColor,
|
||||
closeSettings: () => ipcRenderer.send('close-settings'),
|
||||
doDeleteAllData: () => ipcRenderer.send('delete-all-data'),
|
||||
editCustomColor: ipcEditCustomColor,
|
||||
getConversationsWithCustomColor: ipcGetConversationsWithCustomColor,
|
||||
|
|
Loading…
Reference in a new issue