fix: Fixed workspace menu item rename issue
This commit is contained in:
@@ -9,4 +9,5 @@ export enum KeyboardKey {
|
|||||||
Escape = 'Escape',
|
Escape = 'Escape',
|
||||||
Home = 'Home',
|
Home = 'Home',
|
||||||
End = 'End',
|
End = 'End',
|
||||||
|
Space = ' ',
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,54 +51,56 @@ const WorkspaceMenuItem: FunctionComponent<Props> = ({
|
|||||||
const handleInputBlur: FocusEventHandler<HTMLInputElement> = useCallback(() => {
|
const handleInputBlur: FocusEventHandler<HTMLInputElement> = useCallback(() => {
|
||||||
renameDescriptor(inputValue)
|
renameDescriptor(inputValue)
|
||||||
setIsRenaming(false)
|
setIsRenaming(false)
|
||||||
setInputValue('')
|
|
||||||
}, [inputValue, renameDescriptor])
|
}, [inputValue, renameDescriptor])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MenuRadioButtonItem
|
<div className="relative">
|
||||||
className="flex w-full cursor-pointer items-center border-0 bg-transparent px-3 py-2 text-left text-sm text-text hover:bg-contrast hover:text-foreground focus:bg-info-backdrop focus:shadow-none"
|
<MenuRadioButtonItem
|
||||||
onClick={onClick}
|
className="flex w-full cursor-pointer items-center border-0 bg-transparent px-3 py-2 text-left text-sm text-text hover:bg-contrast hover:text-foreground focus:bg-info-backdrop focus:shadow-none"
|
||||||
checked={descriptor.primary}
|
onClick={onClick}
|
||||||
>
|
checked={descriptor.primary}
|
||||||
<div className="ml-2 flex w-full items-center justify-between">
|
>
|
||||||
{isRenaming ? (
|
<div className="ml-2 flex w-full items-center justify-between">
|
||||||
<input
|
{!isRenaming && <div>{descriptor.label}</div>}
|
||||||
ref={inputRef}
|
{descriptor.primary && !hideOptions && (
|
||||||
type="text"
|
<div className="flex items-center">
|
||||||
value={inputValue}
|
<a
|
||||||
onChange={handleChange}
|
role="button"
|
||||||
onKeyDown={handleInputKeyDown}
|
className="mr-3 flex h-5 w-5 cursor-pointer items-center justify-center border-0 bg-transparent p-0 hover:bg-contrast"
|
||||||
onBlur={handleInputBlur}
|
onClick={(e) => {
|
||||||
/>
|
e.stopPropagation()
|
||||||
) : (
|
setIsRenaming((isRenaming) => !isRenaming)
|
||||||
<div>{descriptor.label}</div>
|
}}
|
||||||
)}
|
>
|
||||||
{descriptor.primary && !hideOptions && (
|
<Icon type="pencil" className="text-neutral" size="medium" />
|
||||||
<div className="flex items-center">
|
</a>
|
||||||
<a
|
<a
|
||||||
role="button"
|
role="button"
|
||||||
className="mr-3 h-5 w-5 cursor-pointer border-0 bg-transparent p-0 hover:bg-contrast"
|
className="flex h-5 w-5 cursor-pointer items-center justify-center border-0 bg-transparent p-0 hover:bg-contrast"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
setIsRenaming((isRenaming) => !isRenaming)
|
onDelete()
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Icon type="pencil" className="text-neutral" size="medium" />
|
<Icon type="trash" className="text-danger" size="medium" />
|
||||||
</a>
|
</a>
|
||||||
<a
|
</div>
|
||||||
role="button"
|
)}
|
||||||
className="h-5 w-5 cursor-pointer border-0 bg-transparent p-0 hover:bg-contrast"
|
</div>
|
||||||
onClick={(e) => {
|
</MenuRadioButtonItem>
|
||||||
e.stopPropagation()
|
{isRenaming && (
|
||||||
onDelete()
|
<input
|
||||||
}}
|
ref={inputRef}
|
||||||
>
|
type="text"
|
||||||
<Icon type="trash" className="text-danger" size="medium" />
|
value={inputValue}
|
||||||
</a>
|
onChange={handleChange}
|
||||||
</div>
|
onKeyDown={handleInputKeyDown}
|
||||||
)}
|
onBlur={handleInputBlur}
|
||||||
</div>
|
onClick={(e) => e.stopPropagation()}
|
||||||
</MenuRadioButtonItem>
|
className="absolute top-1/2 left-11 -translate-y-1/2 bg-default"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user