mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
fix(component): nowrap inline-edit (#5844)
This commit is contained in:
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user