From 41e324fd5159b5bc004aaf3cd478e80fc5f8399f Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Wed, 28 Aug 2024 16:49:19 +1000 Subject: [PATCH] perf(ui): disable `useInert` on modals This hook forcibly updates _all_ portals with `data-hidden=true` when the modal opens - then reverts it when the modal closes. It's intended to help screen readers. Unfortunately, this absolutely tanks performance because we have many portals. React needs to do alot of layout calculations (not re-renders). IMO this behaviour is a bug in chakra. The modals which generated the portals are hidden by default, so this data attr should really be set by default. Dunno why it isn't. --- .../features/changeBoardModal/components/ChangeBoardModal.tsx | 1 + .../features/deleteImageModal/components/DeleteImageModal.tsx | 1 + .../dynamicPrompts/components/DynamicPromptsPreviewModal.tsx | 2 +- .../subpanels/ModelManagerPanel/ModelListItem.tsx | 1 + .../modelManagerV2/subpanels/ModelPanel/ModelConvertButton.tsx | 1 + .../nodes/components/flow/panels/TopPanel/ClearFlowButton.tsx | 1 + .../flow/panels/TopRightPanel/WorkflowEditorSettings.tsx | 2 +- .../queue/components/ClearQueueConfirmationAlertDialog.tsx | 1 + .../components/StylePresetForm/StylePresetModal.tsx | 2 +- .../features/stylePresets/components/StylePresetListItem.tsx | 1 + .../src/features/system/components/AboutModal/AboutModal.tsx | 2 +- .../features/system/components/HotkeysModal/HotkeysModal.tsx | 2 +- .../LoadWorkflowFromGraphModal/LoadWorkflowFromGraphModal.tsx | 2 +- .../components/NewWorkflowConfirmationAlertDialog.tsx | 1 + .../workflowLibrary/components/WorkflowLibraryModal.tsx | 2 +- 15 files changed, 15 insertions(+), 7 deletions(-) diff --git a/invokeai/frontend/web/src/features/changeBoardModal/components/ChangeBoardModal.tsx b/invokeai/frontend/web/src/features/changeBoardModal/components/ChangeBoardModal.tsx index 175bf9fede..d6d9a46731 100644 --- a/invokeai/frontend/web/src/features/changeBoardModal/components/ChangeBoardModal.tsx +++ b/invokeai/frontend/web/src/features/changeBoardModal/components/ChangeBoardModal.tsx @@ -83,6 +83,7 @@ const ChangeBoardModal = () => { acceptCallback={handleChangeBoard} acceptButtonText={t('boards.move')} cancelButtonText={t('boards.cancel')} + useInert={false} > diff --git a/invokeai/frontend/web/src/features/deleteImageModal/components/DeleteImageModal.tsx b/invokeai/frontend/web/src/features/deleteImageModal/components/DeleteImageModal.tsx index 0cd4630243..6eff406b36 100644 --- a/invokeai/frontend/web/src/features/deleteImageModal/components/DeleteImageModal.tsx +++ b/invokeai/frontend/web/src/features/deleteImageModal/components/DeleteImageModal.tsx @@ -81,6 +81,7 @@ const DeleteImageModal = () => { cancelButtonText={t('boards.cancel')} acceptButtonText={t('controlnet.delete')} acceptCallback={handleDelete} + useInert={false} > diff --git a/invokeai/frontend/web/src/features/dynamicPrompts/components/DynamicPromptsPreviewModal.tsx b/invokeai/frontend/web/src/features/dynamicPrompts/components/DynamicPromptsPreviewModal.tsx index 620bda597f..f2929fee79 100644 --- a/invokeai/frontend/web/src/features/dynamicPrompts/components/DynamicPromptsPreviewModal.tsx +++ b/invokeai/frontend/web/src/features/dynamicPrompts/components/DynamicPromptsPreviewModal.tsx @@ -20,7 +20,7 @@ export const DynamicPromptsModal = memo(() => { const { isOpen, onClose } = useDynamicPromptsModal(); return ( - + {t('dynamicPrompts.dynamicPrompts')} diff --git a/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelManagerPanel/ModelListItem.tsx b/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelManagerPanel/ModelListItem.tsx index 8bfcbd7351..60e4964b6d 100644 --- a/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelManagerPanel/ModelListItem.tsx +++ b/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelManagerPanel/ModelListItem.tsx @@ -123,6 +123,7 @@ const ModelListItem = ({ model }: ModelListItemProps) => { title={t('modelManager.deleteModel')} acceptCallback={handleModelDelete} acceptButtonText={t('modelManager.delete')} + useInert={false} > {t('modelManager.deleteMsg1')} diff --git a/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/ModelConvertButton.tsx b/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/ModelConvertButton.tsx index 70775842f8..14119374d4 100644 --- a/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/ModelConvertButton.tsx +++ b/invokeai/frontend/web/src/features/modelManagerV2/subpanels/ModelPanel/ModelConvertButton.tsx @@ -67,6 +67,7 @@ export const ModelConvertButton = memo(({ modelConfig }: ModelConvertProps) => { acceptButtonText={`${t('modelManager.convert')}`} isOpen={isOpen} onClose={onClose} + useInert={false} > {t('modelManager.convertToDiffusersHelpText1')} diff --git a/invokeai/frontend/web/src/features/nodes/components/flow/panels/TopPanel/ClearFlowButton.tsx b/invokeai/frontend/web/src/features/nodes/components/flow/panels/TopPanel/ClearFlowButton.tsx index 0804fe02ff..87f7ad71ce 100644 --- a/invokeai/frontend/web/src/features/nodes/components/flow/panels/TopPanel/ClearFlowButton.tsx +++ b/invokeai/frontend/web/src/features/nodes/components/flow/panels/TopPanel/ClearFlowButton.tsx @@ -47,6 +47,7 @@ const ClearFlowButton = () => { onClose={onClose} title={t('nodes.clearWorkflow')} acceptCallback={handleNewWorkflow} + useInert={false} > {t('nodes.clearWorkflowDesc')} diff --git a/invokeai/frontend/web/src/features/nodes/components/flow/panels/TopRightPanel/WorkflowEditorSettings.tsx b/invokeai/frontend/web/src/features/nodes/components/flow/panels/TopRightPanel/WorkflowEditorSettings.tsx index 5a3f810306..395492f68f 100644 --- a/invokeai/frontend/web/src/features/nodes/components/flow/panels/TopRightPanel/WorkflowEditorSettings.tsx +++ b/invokeai/frontend/web/src/features/nodes/components/flow/panels/TopRightPanel/WorkflowEditorSettings.tsx @@ -102,7 +102,7 @@ const WorkflowEditorSettings = ({ children }: Props) => { <> {children({ onOpen })} - + {t('nodes.workflowSettings')} diff --git a/invokeai/frontend/web/src/features/queue/components/ClearQueueConfirmationAlertDialog.tsx b/invokeai/frontend/web/src/features/queue/components/ClearQueueConfirmationAlertDialog.tsx index b90d66073e..3a5833eee9 100644 --- a/invokeai/frontend/web/src/features/queue/components/ClearQueueConfirmationAlertDialog.tsx +++ b/invokeai/frontend/web/src/features/queue/components/ClearQueueConfirmationAlertDialog.tsx @@ -22,6 +22,7 @@ export const ClearQueueConfirmationsAlertDialog = memo(() => { title={t('queue.clearTooltip')} acceptCallback={clearQueue} acceptButtonText={t('queue.clear')} + useInert={false} > {t('queue.clearQueueAlertDialog')}
diff --git a/invokeai/frontend/web/src/features/stylePresets/components/StylePresetForm/StylePresetModal.tsx b/invokeai/frontend/web/src/features/stylePresets/components/StylePresetForm/StylePresetModal.tsx index 5ae1db7af9..30c99b43f7 100644 --- a/invokeai/frontend/web/src/features/stylePresets/components/StylePresetForm/StylePresetModal.tsx +++ b/invokeai/frontend/web/src/features/stylePresets/components/StylePresetForm/StylePresetModal.tsx @@ -67,7 +67,7 @@ export const StylePresetModal = () => { }, [stylePresetModalState.prefilledFormData]); return ( - + {modalTitle} diff --git a/invokeai/frontend/web/src/features/stylePresets/components/StylePresetListItem.tsx b/invokeai/frontend/web/src/features/stylePresets/components/StylePresetListItem.tsx index 1387b964b8..30f5e87627 100644 --- a/invokeai/frontend/web/src/features/stylePresets/components/StylePresetListItem.tsx +++ b/invokeai/frontend/web/src/features/stylePresets/components/StylePresetListItem.tsx @@ -179,6 +179,7 @@ export const StylePresetListItem = ({ preset }: { preset: StylePresetRecordWithI acceptCallback={handleDeletePreset} acceptButtonText={t('common.delete')} cancelButtonText={t('common.cancel')} + useInert={false} >

{t('stylePresets.deleteTemplate2')}

diff --git a/invokeai/frontend/web/src/features/system/components/AboutModal/AboutModal.tsx b/invokeai/frontend/web/src/features/system/components/AboutModal/AboutModal.tsx index d333b64ebf..4eb6182ecc 100644 --- a/invokeai/frontend/web/src/features/system/components/AboutModal/AboutModal.tsx +++ b/invokeai/frontend/web/src/features/system/components/AboutModal/AboutModal.tsx @@ -53,7 +53,7 @@ const AboutModal = ({ children }: AboutModalProps) => { {cloneElement(children, { onClick: onOpen, })} - + {t('accessibility.about')} diff --git a/invokeai/frontend/web/src/features/system/components/HotkeysModal/HotkeysModal.tsx b/invokeai/frontend/web/src/features/system/components/HotkeysModal/HotkeysModal.tsx index 0a823b8dfa..5189520ad3 100644 --- a/invokeai/frontend/web/src/features/system/components/HotkeysModal/HotkeysModal.tsx +++ b/invokeai/frontend/web/src/features/system/components/HotkeysModal/HotkeysModal.tsx @@ -70,7 +70,7 @@ const HotkeysModal = ({ children }: HotkeysModalProps) => { {cloneElement(children, { onClick: onOpen, })} - + {t('hotkeys.keyboardShortcuts')} diff --git a/invokeai/frontend/web/src/features/workflowLibrary/components/LoadWorkflowFromGraphModal/LoadWorkflowFromGraphModal.tsx b/invokeai/frontend/web/src/features/workflowLibrary/components/LoadWorkflowFromGraphModal/LoadWorkflowFromGraphModal.tsx index 6ecb51a528..9f06ce321a 100644 --- a/invokeai/frontend/web/src/features/workflowLibrary/components/LoadWorkflowFromGraphModal/LoadWorkflowFromGraphModal.tsx +++ b/invokeai/frontend/web/src/features/workflowLibrary/components/LoadWorkflowFromGraphModal/LoadWorkflowFromGraphModal.tsx @@ -62,7 +62,7 @@ export const LoadWorkflowFromGraphModal = () => { onClose(); }, [dispatch, onClose, workflowRaw]); return ( - + {t('workflows.loadFromGraph')} diff --git a/invokeai/frontend/web/src/features/workflowLibrary/components/NewWorkflowConfirmationAlertDialog.tsx b/invokeai/frontend/web/src/features/workflowLibrary/components/NewWorkflowConfirmationAlertDialog.tsx index 704412052a..c0b5fee85b 100644 --- a/invokeai/frontend/web/src/features/workflowLibrary/components/NewWorkflowConfirmationAlertDialog.tsx +++ b/invokeai/frontend/web/src/features/workflowLibrary/components/NewWorkflowConfirmationAlertDialog.tsx @@ -46,6 +46,7 @@ export const NewWorkflowConfirmationAlertDialog = memo((props: Props) => { onClose={onClose} title={t('nodes.newWorkflow')} acceptCallback={handleNewWorkflow} + useInert={false} > {t('nodes.newWorkflowDesc')} diff --git a/invokeai/frontend/web/src/features/workflowLibrary/components/WorkflowLibraryModal.tsx b/invokeai/frontend/web/src/features/workflowLibrary/components/WorkflowLibraryModal.tsx index 7aaac5ec14..ca3148d9cb 100644 --- a/invokeai/frontend/web/src/features/workflowLibrary/components/WorkflowLibraryModal.tsx +++ b/invokeai/frontend/web/src/features/workflowLibrary/components/WorkflowLibraryModal.tsx @@ -16,7 +16,7 @@ const WorkflowLibraryModal = () => { const { t } = useTranslation(); const { isOpen, onClose } = useWorkflowLibraryModalContext(); return ( - + {t('workflows.workflowLibrary')}