mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-21 16:38:23 +01:00
Auto-select workspace name (#1464)
This commit is contained in:
parent
9805ce4921
commit
f7875bc4f0
@ -67,6 +67,7 @@ interface InputProps {
|
||||
required?: boolean;
|
||||
maxLength?: number;
|
||||
autoFocus?: boolean;
|
||||
autoSelect?: boolean;
|
||||
disabled?: boolean;
|
||||
isNumber?: boolean;
|
||||
inputRef?: React.MutableRefObject<any>;
|
||||
@ -88,6 +89,7 @@ const Input = memo(
|
||||
required,
|
||||
maxLength,
|
||||
autoFocus,
|
||||
autoSelect,
|
||||
disabled,
|
||||
isNumber,
|
||||
manageFocus,
|
||||
@ -114,6 +116,9 @@ const Input = memo(
|
||||
};
|
||||
|
||||
const handleFocus = () => {
|
||||
if (autoSelect) {
|
||||
inputRef.current?.select();
|
||||
}
|
||||
manageFocus?.(true);
|
||||
onFocus?.();
|
||||
};
|
||||
|
@ -145,7 +145,7 @@
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.color-icon-selector {
|
||||
.workspace-editor {
|
||||
width: 100%;
|
||||
.input {
|
||||
margin: 5px 0 10px;
|
||||
|
@ -106,7 +106,7 @@ const IconSelector = memo(({ icons, selectedIcon, onSelect, className }: IconSel
|
||||
);
|
||||
});
|
||||
|
||||
interface ColorAndIconSelectorProps {
|
||||
interface WorkspaceEditorProps {
|
||||
title: string;
|
||||
icon: string;
|
||||
color: string;
|
||||
@ -116,7 +116,7 @@ interface ColorAndIconSelectorProps {
|
||||
onIconChange: (newIcon: string) => void;
|
||||
onDeleteWorkspace: () => void;
|
||||
}
|
||||
const ColorAndIconSelector = memo(
|
||||
const WorkspaceEditor = memo(
|
||||
({
|
||||
title,
|
||||
icon,
|
||||
@ -126,23 +126,25 @@ const ColorAndIconSelector = memo(
|
||||
onColorChange,
|
||||
onIconChange,
|
||||
onDeleteWorkspace,
|
||||
}: ColorAndIconSelectorProps) => {
|
||||
}: WorkspaceEditorProps) => {
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (focusInput && inputRef.current) {
|
||||
inputRef.current.focus();
|
||||
inputRef.current.select();
|
||||
}
|
||||
}, [focusInput]);
|
||||
|
||||
return (
|
||||
<div className="color-icon-selector">
|
||||
<div className="workspace-editor">
|
||||
<Input
|
||||
ref={inputRef}
|
||||
className={clsx("vertical-padding-3", { error: title === "" })}
|
||||
onChange={onTitleChange}
|
||||
value={title}
|
||||
autoFocus
|
||||
autoSelect
|
||||
/>
|
||||
<ColorSelector selectedColor={color} colors={colors} onSelect={onColorChange} />
|
||||
<IconSelector selectedIcon={icon} icons={icons} onSelect={onIconChange} />
|
||||
@ -354,7 +356,7 @@ const WorkspaceSwitcherItem = ({
|
||||
</div>
|
||||
</ExpandableMenuItemGroupTitle>
|
||||
<ExpandableMenuItem>
|
||||
<ColorAndIconSelector
|
||||
<WorkspaceEditor
|
||||
title={workspace.name}
|
||||
icon={workspace.icon}
|
||||
color={workspace.color}
|
||||
|
Loading…
Reference in New Issue
Block a user