refactor: input component (#2999)

This commit is contained in:
Alex Yang
2023-07-04 14:52:46 +08:00
parent 394d535906
commit 65c6479ee4
6 changed files with 30 additions and 28 deletions

View File

@@ -14,7 +14,7 @@ import { useSetAtom } from 'jotai';
import type { KeyboardEvent } from 'react';
import { useEffect } from 'react';
import { useLayoutEffect } from 'react';
import { useCallback, useRef, useState } from 'react';
import { useCallback, useState } from 'react';
import { openDisableCloudAlertModalAtom } from '../../../atoms';
import { useAppHelper } from '../../../hooks/use-workspaces';
@@ -45,7 +45,6 @@ const NameWorkspaceContent = ({
onClose,
}: NameWorkspaceContentProps) => {
const [workspaceName, setWorkspaceName] = useState('');
const isComposition = useRef(false);
const handleCreateWorkspace = useCallback(() => {
onConfirmName(workspaceName);
@@ -53,7 +52,7 @@ const NameWorkspaceContent = ({
const handleKeyDown = useCallback(
(event: KeyboardEvent<HTMLInputElement>) => {
if (event.key === 'Enter' && workspaceName && !isComposition.current) {
if (event.key === 'Enter' && workspaceName) {
handleCreateWorkspace();
}
},
@@ -76,12 +75,6 @@ const NameWorkspaceContent = ({
maxLength={64}
minLength={0}
onChange={setWorkspaceName}
onCompositionStart={() => {
isComposition.current = true;
}}
onCompositionEnd={() => {
isComposition.current = false;
}}
/>
<div className={style.buttonGroup}>
<Button

View File

@@ -86,7 +86,6 @@ export const WorkspaceDeleteModal = ({
onChange={setDeleteStr}
data-testid="delete-workspace-input"
placeholder={t['Placeholder of delete workspace']()}
value={deleteStr}
width={315}
height={42}
/>

View File

@@ -71,7 +71,7 @@ export const ProfilePanel: FC<{
<Input
width={280}
height={32}
value={input}
defaultValue={input}
data-testid="workspace-name-input"
placeholder={t['Workspace Name']()}
maxLength={64}