Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix(web): setting panel refresh (#3070)

Alex Yang28653d6892fd
diff --git a/apps/web/src/adapters/local/index.tsx b/apps/web/src/adapters/local/index.tsx
index ed91d19e92..8a2e16d2e8 100644
--- a/apps/web/src/adapters/local/index.tsx
+++ b/apps/web/src/adapters/local/index.tsx
@@ -113,6 +113,7 @@ export const LocalAdapter: WorkspaceAdapter<WorkspaceFlavour.LOCAL> = {
<NewWorkspaceSettingDetail
onDeleteWorkspace={onDeleteWorkspace}
workspace={currentWorkspace}
+ key={currentWorkspace.id}
onTransferWorkspace={onTransformWorkspace}
/>
);
diff --git a/apps/web/src/components/affine/new-workspace-setting-detail/profile.tsx b/apps/web/src/components/affine/new-workspace-setting-detail/profile.tsx
index f9dc8fd588..7d3fd4f3b3 100644
--- a/apps/web/src/components/affine/new-workspace-setting-detail/profile.tsx
+++ b/apps/web/src/components/affine/new-workspace-setting-detail/profile.tsx
@@ -4,7 +4,7 @@ import { useAFFiNEI18N } from '@affine/i18n/hooks';
import { DoneIcon } from '@blocksuite/icons';
import { useBlockSuiteWorkspaceAvatarUrl } from '@toeverything/hooks/use-block-suite-workspace-avatar-url';
import { useBlockSuiteWorkspaceName } from '@toeverything/hooks/use-block-suite-workspace-name';
-import { type FC, useCallback, useRef, useState } from 'react';
+import { type FC, useCallback, useState } from 'react';
import type { AffineOfficialWorkspace } from '../../../shared';
import { Upload } from '../../pure/file-upload';
@@ -38,16 +38,12 @@ export const ProfilePanel: FC<{
workspace.blockSuiteWorkspace
);
- const [prevName, setPrevName] = useState(
- workspace.blockSuiteWorkspace.meta.name
- );
const [name, setName] = useBlockSuiteWorkspaceName(
workspace.blockSuiteWorkspace
);
const [input, setInput] = useState<string>(name);
- const inputRef = useRef<HTMLInputElement>(null);
const handleUpdateWorkspaceName = useCallback(
(name: string) => {
setName(name);
@@ -56,13 +52,6 @@ export const ProfilePanel: FC<{
[setName, t]
);
- if (prevName !== name) {
- setPrevName(name);
- if (inputRef.current) {
- inputRef.current.value = name;
- }
- }
-
return (
<div className={style.profileWrapper}>
<div className={style.avatarWrapper}>
@@ -81,7 +70,6 @@ export const ProfilePanel: FC<{
</div>
<div className={style.profileHandlerWrapper}>
<Input
- ref={inputRef}
width={280}
height={32}
defaultValue={input}