From 81817532f8fbed227fa5914bc5f240406452d22b Mon Sep 17 00:00:00 2001
From: psychedelicious <4822129+psychedelicious@users.noreply.github.com>
Date: Sat, 8 Jul 2023 23:48:32 +1000
Subject: [PATCH 1/2] fix(ui): fix tab translations
model manager was using the wrong key due to the tabs render func subbing values in. made translation key a prop of a tab item.
---
.../web/src/features/ui/components/InvokeTabs.tsx | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/invokeai/frontend/web/src/features/ui/components/InvokeTabs.tsx b/invokeai/frontend/web/src/features/ui/components/InvokeTabs.tsx
index c618997f03..9eb99afa3e 100644
--- a/invokeai/frontend/web/src/features/ui/components/InvokeTabs.tsx
+++ b/invokeai/frontend/web/src/features/ui/components/InvokeTabs.tsx
@@ -41,6 +41,7 @@ import UnifiedCanvasTab from './tabs/UnifiedCanvas/UnifiedCanvasTab';
export interface InvokeTabInfo {
id: InvokeTabName;
+ translationKey: string;
icon: ReactNode;
content: ReactNode;
}
@@ -48,26 +49,31 @@ export interface InvokeTabInfo {
const tabs: InvokeTabInfo[] = [
{
id: 'txt2img',
+ translationKey: 'common.txt2img',
icon: ,
content: ,
},
{
id: 'img2img',
+ translationKey: 'common.img2img',
icon: ,
content: ,
},
{
id: 'unifiedCanvas',
+ translationKey: 'common.unifiedCanvas',
icon: ,
content: ,
},
{
id: 'nodes',
+ translationKey: 'common.nodes',
icon: ,
content: ,
},
{
id: 'modelManager',
+ translationKey: 'modelManager.modelManager',
icon: ,
content: ,
},
@@ -146,12 +152,12 @@ const InvokeTabs = () => {
- {String(t(`common.${tab.id}` as ResourceKey))}
+ {String(t(tab.translationKey as ResourceKey))}
{tab.icon}
From be06d4c0afb2070552112dd160fa7705f250ebe4 Mon Sep 17 00:00:00 2001
From: psychedelicious <4822129+psychedelicious@users.noreply.github.com>
Date: Sat, 8 Jul 2023 23:37:34 +1000
Subject: [PATCH 2/2] fix(ui): fix selection on dropdowns
Mantine's multiselect does not let you edit the search box with mouse, paste into it, etc. Normal select is fine.
I can't remember why I made Lora etc multiselects, but everything seems to work with normal selects, so I've change to that.
---
.../components/IAIMantineMultiSelect.tsx | 1 +
.../common/components/IAIMantineSelect.tsx | 26 ++++++++++++-
.../components/ParamEmbeddingPopover.tsx | 18 ++++-----
.../lora/components/ParamLoraSelect.tsx | 18 +++++----
.../features/nodes/components/AddNodeMenu.tsx | 39 ++++++++++++-------
5 files changed, 68 insertions(+), 34 deletions(-)
diff --git a/invokeai/frontend/web/src/common/components/IAIMantineMultiSelect.tsx b/invokeai/frontend/web/src/common/components/IAIMantineMultiSelect.tsx
index e52ec63810..dc6db707e7 100644
--- a/invokeai/frontend/web/src/common/components/IAIMantineMultiSelect.tsx
+++ b/invokeai/frontend/web/src/common/components/IAIMantineMultiSelect.tsx
@@ -59,6 +59,7 @@ const IAIMantineMultiSelect = (props: IAIMultiSelectProps) => {
onKeyDown={handleKeyDown}
onKeyUp={handleKeyUp}
searchable={searchable}
+ maxDropdownHeight={300}
styles={() => ({
label: {
color: mode(base700, base300)(colorMode),
diff --git a/invokeai/frontend/web/src/common/components/IAIMantineSelect.tsx b/invokeai/frontend/web/src/common/components/IAIMantineSelect.tsx
index 80e6c24ace..99d0e8a615 100644
--- a/invokeai/frontend/web/src/common/components/IAIMantineSelect.tsx
+++ b/invokeai/frontend/web/src/common/components/IAIMantineSelect.tsx
@@ -3,7 +3,7 @@ import { Select, SelectProps } from '@mantine/core';
import { useAppDispatch } from 'app/store/storeHooks';
import { useChakraThemeTokens } from 'common/hooks/useChakraThemeTokens';
import { shiftKeyPressed } from 'features/ui/store/hotkeysSlice';
-import { KeyboardEvent, memo, useCallback } from 'react';
+import { KeyboardEvent, RefObject, memo, useCallback, useState } from 'react';
import { mode } from 'theme/util/mode';
export type IAISelectDataType = {
@@ -14,10 +14,11 @@ export type IAISelectDataType = {
type IAISelectProps = SelectProps & {
tooltip?: string;
+ inputRef?: RefObject;
};
const IAIMantineSelect = (props: IAISelectProps) => {
- const { searchable = true, tooltip, ...rest } = props;
+ const { searchable = true, tooltip, inputRef, onChange, ...rest } = props;
const dispatch = useAppDispatch();
const {
base50,
@@ -38,7 +39,9 @@ const IAIMantineSelect = (props: IAISelectProps) => {
} = useChakraThemeTokens();
const { colorMode } = useColorMode();
+ const [searchValue, setSearchValue] = useState('');
+ // we want to capture shift keypressed even when an input is focused
const handleKeyDown = useCallback(
(e: KeyboardEvent) => {
if (e.shiftKey) {
@@ -57,14 +60,33 @@ const IAIMantineSelect = (props: IAISelectProps) => {
[dispatch]
);
+ // wrap onChange to clear search value on select
+ const handleChange = useCallback(
+ (v: string | null) => {
+ setSearchValue('');
+
+ if (!onChange) {
+ return;
+ }
+
+ onChange(v);
+ },
+ [onChange]
+ );
+
const [boxShadow] = useToken('shadows', ['dark-lg']);
return (