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(component): nowrap inline-edit (#5844)

Cats Juiceed0d67ee56f7
diff --git a/packages/frontend/component/src/ui/editable/inline-edit.tsx b/packages/frontend/component/src/ui/editable/inline-edit.tsx
index 845a3f4e8c..07e0de7f7e 100644
--- a/packages/frontend/component/src/ui/editable/inline-edit.tsx
+++ b/packages/frontend/component/src/ui/editable/inline-edit.tsx
@@ -7,6 +7,7 @@ import {
useCallback,
useEffect,
useImperativeHandle,
+ useMemo,
useRef,
useState,
} from 'react';
@@ -139,6 +140,11 @@ export const InlineEdit = ({
setEditingValue(value);
}, [value]);
+ // to make sure text is not wrapped, and multi-space is shown normally
+ const displayValue = useMemo(() => {
+ return editingValue ? editingValue.replace(/\n/g, '') : '';
+ }, [editingValue]);
+
// to make sure input's style is the same as displayed text
const inputWrapperInheritsStyles = {
margin: 'inherit',
@@ -172,9 +178,9 @@ export const InlineEdit = ({
onDoubleClick={onDoubleClick}
className={clsx(styles.inlineEdit)}
>
- {editingValue}
+ {displayValue}
- {!editingValue && (
+ {!displayValue && (
<Placeholder
className={placeholderClassName}
label={placeholder}