Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

feat(design): add clear icon on defined name comment; fix: overlaying a value on clear icon (#6043)

Roman Sergeev1748f5fe0247
diff --git a/packages/design/src/components/input/Input.tsx b/packages/design/src/components/input/Input.tsx
index 64f9f6a27d..24959f1f95 100644
--- a/packages/design/src/components/input/Input.tsx
+++ b/packages/design/src/components/input/Input.tsx
@@ -118,6 +118,10 @@ export const Input = forwardRef<HTMLInputElement, IInputProps>(
return () => observer?.disconnect();
}, [slotRef.current]);
+ useEffect(() => {
+ if (allowClear && !(slot && slotRef.current)) setPaddingRight(26);
+ }, []); // only enough for init, otherwise it works again when you click it
+
return (
<div
data-u-comp="input"
diff --git a/packages/sheets-ui/src/views/defined-name/DefinedNameInput.tsx b/packages/sheets-ui/src/views/defined-name/DefinedNameInput.tsx
index 811dbbbc45..0ec7640df5 100644
--- a/packages/sheets-ui/src/views/defined-name/DefinedNameInput.tsx
+++ b/packages/sheets-ui/src/views/defined-name/DefinedNameInput.tsx
@@ -282,6 +282,7 @@ export const DefinedNameInput = (props: IDefinedNameInputProps) => {
placeholder={localeService.t('definedName.inputCommentPlaceholder')}
value={commentValue}
onChange={setCommentValue}
+ allowClear
/>
</div>
<div