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.

fix(base-ui): fix set font size input,style,enter save (#207)

Dushusir55c5deba5eec
diff --git a/packages/base-ui/src/Components/CustomLabel/CustomLabel.tsx b/packages/base-ui/src/Components/CustomLabel/CustomLabel.tsx
index 2cd18f3f17..1f6eee340a 100644
--- a/packages/base-ui/src/Components/CustomLabel/CustomLabel.tsx
+++ b/packages/base-ui/src/Components/CustomLabel/CustomLabel.tsx
@@ -24,7 +24,15 @@ function getLocale(context: Partial<AppContextValues>, name: string) {
export interface INeoCustomLabelProps {
value?: string | number | undefined;
selected?: boolean;
+ /**
+ * Triggered after value change
+ */
onChange?(v: string | number): void;
+ /**
+ * Triggered after input Enter or Blur
+ */
+ onValueChange?(v: string | number): void;
+ onFocus?: (e: React.FocusEvent<HTMLInputElement, Element>) => void;
}
/**
@@ -33,10 +41,11 @@ export interface INeoCustomLabelProps {
* @returns
*/
export function NeoCustomLabel(
- props: Pick<IMenuSelectorItem<unknown>, 'label' | 'icon' | 'display' | 'title'> & INeoCustomLabelProps
+ props: Pick<IMenuSelectorItem<unknown>, 'label' | 'icon' | 'display' | 'title' | 'max' | 'min'> &
+ INeoCustomLabelProps
): JSX.Element | null {
const context = useContext(AppContext);
- const { display, value, title, icon, label, onChange, selected } = props;
+ const { display, value, title, icon, label, onChange, selected, onFocus, max, min } = props;
if (display === DisplayTypes.COLOR) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -52,7 +61,24 @@ export function NeoCustomLabel(
}
if (display === DisplayTypes.INPUT) {
- return <Input onValueChange={(v) => onChange?.(v as unknown as string)} type="number" value={`${value}`} />;
+ return (
+ <Input
+ onValueChange={(v) => onChange?.(v as unknown as string)}
+ onFocus={onFocus}
+ type="number"
+ value={`${value}`}
+ bordered={false}
+ style={{
+ width: '32px',
+ height: '24px',
+ padding: '2px',
+ textAlign: 'center',
+ background: 'transparent',
+ }}
+ max={max}
+ min={min}
+ />
+ );
}
if (display === DisplayTypes.ICON && icon) {
diff --git a/packages/base-ui/src/Components/Dropdown/index.module.css b/packages/base-ui/src/Components/Dropdown/index.module.css
deleted file mode 100644
index 24ac0f4cea..0000000000
--- a/packages/base-ui/src/Components/Dropdown/index.module.css
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
-1. 所有的变量加到这里,复用
-2. 组件要用的话,在这定义好,导入组件使用
-3. 需要作为皮肤变量的,导入到所有皮肤中导出使用
-*/
-.dropdown {
- padding: 0px 5px;
- position: relative;
- display: flex;
- align-items: center;
-}
-.dropdown .drop-content {
- display: flex;
- justify-content: space-between;
- align-items: center;
-}
-.dropdown .drop-icon {
- height: 100%;
- margin-left: 5px;
- border-left: 1px solid #efefef;
- display: flex;
- align-items: center;
-}
diff --git a/packages/base-ui/src/Components/Input/Input.tsx b/packages/base-ui/src/Components/Input/Input.tsx
index 275e4d5a46..8473782bfe 100644
--- a/packages/base-ui/src/Components/Input/Input.tsx
+++ b/packages/base-ui/src/Components/Input/Input.tsx
@@ -6,6 +6,14 @@ import styles from './Style/index.module.less';
// Component Interface
export interface BaseInputProps extends BaseComponentProps {
+ /**
+ * Input's class name
+ */
+ className?: string;
+
+ /** Semantic DOM style */
+ style?: React.CSSProperties;
+
/**
* The type of input
* @default 'text'
@@ -39,11 +47,6 @@ export interface BaseInputProps extends BaseComponentProps {
*/
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
- /**
- * The callback function that is triggered when Enter key is pressed
- */
- onPressEnter?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
-
/**
* Whether has border style
* @default true
@@ -78,11 +81,6 @@ export interface BaseInputProps extends BaseComponentProps {
onValueChange?: (value: string) => void;
- /**
- * Input's class name
- */
- className?: string;
-
/**
* Whether the input is read only
* @default false
@@ -93,6 +91,16 @@ export interface BaseInputProps extends BaseComponentProps {
* Input's id
*/
id?: string;
+
+ /**
+ * When Type is Number, the maximum value
+ */
+ max?: number;
+
+ /**
+ * When Type is Number, the minimum value
+ */
+ min?: number;
}
/**
@@ -121,13 +129,8 @@ export function Input(props: BaseInputProps) {
};
const handlePressEnter = (e: React.KeyboardEvent<HTMLInputElement>) => {
- const { onPressEnter, onValueChange } = props;
- const v = getValue();
- setValue(v);
if (e.key === 'Enter') {
- onPressEnter?.(e);
ref.current?.blur();
- v && onValueChange?.(v);
}
};
@@ -146,14 +149,45 @@ export function Input(props: BaseInputProps) {
const onBlur = (e: React.FocusEvent<HTMLInputElement, Element>) => {
const { onBlur, onValueChange } = props;
onBlur?.(e);
- const v = getValue();
+ let v = getValue();
+
+ if (v == null) return;
+
+ // Limit the size according to MAX MIN
+ const { max, min } = props;
+ if (props.type === 'number') {
+ if (typeof max === 'number' && +v > max) {
+ setValue(max.toString());
+ v = max.toString();
+ } else if (typeof min === 'number' && +v < min) {
+ setValue(min.toString());
+ v = min.toString();
+ } else {
+ setValue(v);
+ }
+ } else {
+ setValue(v);
+ }
+
v && onValueChange?.(v);
setFocused(false);
};
const getValue = () => ref.current?.value;
- const { id, disabled, type = 'text', placeholder, bordered = true, className = '', readonly, maxLength } = props;
+ const {
+ id,
+ disabled,
+ type = 'text',
+ placeholder,
+ bordered = true,
+ className = '',
+ style = {},
+ readonly,
+ maxLength,
+ max,
+ min,
+ } = props;
const classes = joinClassNames(
styles.input,
@@ -167,6 +201,7 @@ export function Input(props: BaseInputProps) {
return (
<input
type={type}
+ style={style}
onBlur={onBlur}
onFocus={onFocus}
className={classes}
@@ -180,6 +215,8 @@ export function Input(props: BaseInputProps) {
readOnly={readonly}
id={id}
onKeyUp={handlePressEnter}
+ max={max}
+ min={min}
/>
);
}
diff --git a/packages/base-ui/src/Components/Input/Style/mixin.less b/packages/base-ui/src/Components/Input/Style/mixin.less
index 6a04e661ee..3567b414ff 100644
--- a/packages/base-ui/src/Components/Input/Style/mixin.less
+++ b/packages/base-ui/src/Components/Input/Style/mixin.less
@@ -1,14 +1,14 @@
@import '../../../Basics/CSS/Skin/default.module.less';
.active() {
- border-right-width: @border-width-base !important;
+ // border-right-width: @border-width-base !important;
outline: 0;
box-shadow: @box-shadow-base;
}
.hover(@color: var(--primary-color-hover)) {
border-color: @color;
- border-right-width: @border-width-base !important;
+ // border-right-width: @border-width-base !important;
}
.disabled() {
@@ -58,12 +58,11 @@
}
&-borderless {
- border: none;
+ border: @border-width-base @border-style-base transparent;
box-shadow: none;
&:hover {
- border: @border-width-base @border-style-base var(--border-color-base);
- .hover();
+ border: @border-width-base @border-style-base transparent;
}
&:focus,
@@ -72,4 +71,15 @@
.active();
}
}
+
+ // Remove Arrows/Spinners
+ &::-webkit-outer-spin-button,
+ &::-webkit-inner-spin-button{
+ -webkit-appearance: none;
+ margin: 0;
+ }
+
+ &[type=number] {
+ -moz-appearance: textfield;
+ }
}
diff --git a/packages/base-ui/src/Components/InputNumber/Style/index.module.less b/packages/base-ui/src/Components/InputNumber/Style/index.module.less
index 2c16a43b04..40a405b6a2 100644
--- a/packages/base-ui/src/Components/InputNumber/Style/index.module.less
+++ b/packages/base-ui/src/Components/InputNumber/Style/index.module.less
@@ -1,5 +1,5 @@
@import '../../../Basics/CSS/Skin/default.module.less';
-@import './mixin.less';
+@import '../../Input/Style/mixin.less';
.input {
.input();
diff --git a/packages/base-ui/src/Components/InputNumber/Style/mixin.less b/packages/base-ui/src/Components/InputNumber/Style/mixin.less
deleted file mode 100644
index 181e5d7399..0000000000
--- a/packages/base-ui/src/Components/InputNumber/Style/mixin.less
+++ /dev/null
@@ -1,71 +0,0 @@
-@import '../../../Basics/CSS/Skin/default.module.less';
-
-.active() {
- border-right-width: @border-width-base !important;
- outline: 0;
- box-shadow: @box-shadow-base;
-}
-
-.hover(@color: var(--primary-color-hover)) {
- border-color: @color;
- border-right-width: @border-width-base !important;
-}
-
-.disabled() {
- color: var(--disabled-color);
- background-color: var(--disabled-bg);
- border-color: var(--border-color-base);
- box-shadow: none;
- cursor: not-allowed;
- opacity: 1;
-
- &:hover {
- .hover(var(--border-color-base));
- }
-}
-
-.input() {
- position: relative;
- display: inline-block;
- width: 100%;
- min-width: 0;
- box-sizing: border-box;
- padding: 2px 7px;
- color: var(--text-color);
- font-size: @font-size-base;
- line-height: @line-height-base;
- background-color: var(--bg);
- background-image: none;
- border: @border-width-base @border-style-base var(--border-color-base);
- border-radius: @border-radius-base;
- transition: all 0.3s;
-
- &:hover {
- .hover();
- }
-
- &:focus,
- &-focused {
- .active();
- }
-
- &[disabled] {
- .disabled();
- }
-
- &-disabled {
- .disabled();
- }
-
- &-borderless {
- border: none;
- box-shadow: none;
-
- &:focus,
- &-focused {
- border-width: 0;
- outline: 0;
- box-shadow: none;
- }
- }
-}
\ No newline at end of file
diff --git a/packages/base-ui/src/Components/Item/index.module.less b/packages/base-ui/src/Components/Item/index.module.less
index 829565629b..623ce00547 100644
--- a/packages/base-ui/src/Components/Item/index.module.less
+++ b/packages/base-ui/src/Components/Item/index.module.less
@@ -1,5 +1,5 @@
.select-item {
- padding: 0 14px 0 25px;
+ padding-left: 24px;
display: flex;
align-items: center;
position: relative;
diff --git a/packages/base-ui/src/Components/Menu/Menu.tsx b/packages/base-ui/src/Components/Menu/Menu.tsx
index 71a8b702e4..ea392e6247 100644
--- a/packages/base-ui/src/Components/Menu/Menu.tsx
+++ b/packages/base-ui/src/Components/Menu/Menu.tsx
@@ -342,6 +342,7 @@
// }
// }
// }
+import { isRealNum } from '@univerjs/core';
import React, { useContext, useEffect, useRef, useState } from 'react';
import { of } from 'rxjs';
@@ -359,7 +360,7 @@ import {
} from '../../services/menu/menu';
import { IMenuService } from '../../services/menu/menu.service';
import { joinClassNames } from '../../Utils';
-import { CustomLabel, NeoCustomLabel } from '../CustomLabel/CustomLabel';
+import { NeoCustomLabel } from '../CustomLabel/CustomLabel';
import { useObservable } from '../hooks/observable';
import { BaseMenuItem } from '../Item/Item';
import { DisplayTypes } from '../Select/Select';
@@ -470,6 +471,7 @@ export const Menu = (props: BaseMenuProps) => {
useEffect(() => {
const { show = false } = props;
+
showMenu(show);
}, [props.show]);
@@ -596,8 +598,10 @@ export const Menu = (props: BaseMenuProps) => {
className={joinClassNames(
styles.colsMenuitem,
option.disabled ? styles.colsMenuitemDisabled : ''
+ // String(value) === String(option.value) ? styles.selectItemSelected : '' // Set the background color of Item
)}
onClick={() => {
+ // Execute the callback function
if (option.value) {
onOptionSelect?.({
...option,
@@ -606,8 +610,8 @@ export const Menu = (props: BaseMenuProps) => {
}
}}
>
- <CustomLabel
- selected={value === option.value}
+ <NeoCustomLabel
+ selected={String(value) === String(option.value)} // use √ for select
value={String(option.value)}
display={display}
label={option.label}
@@ -687,15 +691,6 @@ export function MenuItem({ menuItem, index, onClick }: IMenuItemProps) {
}
};
- /**
- * user input change value from CustomLabel
- * @param e
- */
- const onChange = (v: string | number) => {
- // const newValue = isRealNum(v) && typeof v === 'string' ? parseInt(v) : v;
- // setValue(newValue);
- };
-
useEffect(() => {
getSubMenus();
@@ -705,6 +700,16 @@ export function MenuItem({ menuItem, index, onClick }: IMenuItemProps) {
const disabled = useObservable<boolean>(menuItem.disabled$ || of(false), false, true);
const hidden = useObservable(menuItem.hidden$ || of(false), false, true);
const value = useObservable<MenuItemDefaultValueType>(menuItem.value$ || of(undefined), undefined, true);
+ const [inputValue, setInputValue] = useState(value);
+
+ /**
+ * user input change value from CustomLabel
+ * @param e
+ */
+ const onChange = (v: string | number) => {
+ const newValue = isRealNum(v) && typeof v === 'string' ? parseInt(v) : v;
+ setInputValue(newValue);
+ };
const renderButtonType = () => {
const item = menuItem as IDisplayMenuItem<IMenuButtonItem>;
@@ -716,16 +721,18 @@ export function MenuItem({ menuItem, index, onClick }: IMenuItemProps) {
// disabled={disabled} // FIXME disabled is not working
onClick={() => {
// commandService.executeCommand(item.id, { value });// move to business components
- onClick({ value, id: item.id }); // merge cell
+ onClick({ value: inputValue, id: item.id }); // merge cell
}}
>
<NeoCustomLabel
display={display}
- value={value}
+ value={inputValue}
title={title}
label={label}
- onChange={(v) => {
- onChange(v);
+ onChange={onChange}
+ onValueChange={() => {
+ // Right-click the menu for the title bar, and the Enter key triggers after entering the row height
+ onClick({ value: inputValue, id: item.id });
}}
></NeoCustomLabel>
</li>
@@ -744,11 +751,13 @@ export function MenuItem({ menuItem, index, onClick }: IMenuItemProps) {
>
<NeoCustomLabel
title={item.title}
- value={value}
+ value={inputValue}
onChange={onChange}
icon={item.icon}
display={item.display}
label={item.label}
+ max={item.max}
+ min={item.min}
></NeoCustomLabel>
{item.shortcut && ` (${item.shortcut})`}
{(menuItems.length > 0 || (item as IMenuSelectorItem).selections?.length) && (
diff --git a/packages/base-ui/src/Components/Menu/index.module.less b/packages/base-ui/src/Components/Menu/index.module.less
index 24979997cf..bb5d12e3b9 100644
--- a/packages/base-ui/src/Components/Menu/index.module.less
+++ b/packages/base-ui/src/Components/Menu/index.module.less
@@ -22,13 +22,19 @@
color: var(--text-color);
cursor: pointer;
list-style: none;
- margin: 0;
+ // margin: 0;
white-space: nowrap;
vertical-align: middle;
user-select: none;
- padding: 3px 0;
- &:hover {
+ // FIXME use token instead
+ padding: 4px;
+ margin: 4px 8px;
+ font-size: 14px;
+
+ border-radius: var(--border-radius-base);
+
+ &:hover,&.select-item-selected {
background-color: var(--bg-color-hover);
}
}
diff --git a/packages/base-ui/src/Components/Select/Select.tsx b/packages/base-ui/src/Components/Select/Select.tsx
index 70e18021e3..567b9647f3 100644
--- a/packages/base-ui/src/Components/Select/Select.tsx
+++ b/packages/base-ui/src/Components/Select/Select.tsx
@@ -393,6 +393,8 @@ export interface BaseSelectProps {
options?: IValueOption[];
title?: string;
onClose?: () => void;
+ max?: number; // input maximum value
+ min?: number; // INPUT minimum value
}
export function Select(props: BaseSelectProps) {
@@ -433,7 +435,6 @@ export function Select(props: BaseSelectProps) {
list[i].children = resetMenu(children[i].children as BaseSelectChildrenProps[]);
}
}
-
return list;
};
@@ -613,7 +614,6 @@ export function Select(props: BaseSelectProps) {
<div className={`${styles.selectInput} ${className}`}>
<Dropdown onMainClick={onMainClick} tooltip={tooltip} menu={{ menu, onClick }}>
<Input
- onPressEnter={(e) => handlePressEnter(e)}
onBlur={onPressEnter}
type="number"
value={`${props.label as number}` ?? (content as string)}
@@ -666,7 +666,7 @@ export function Select(props: BaseSelectProps) {
};
const renderNeo = () => {
- const { tooltip, onClick, display, value, icon, title, id, options, type, onClose } = props;
+ const { tooltip, onClick, display, value, icon, title, id, options, type, onClose, max, min } = props;
const onClickInner = (...args: unknown[]) => {
onClick?.(args[1] as number | string);
@@ -680,7 +680,7 @@ export function Select(props: BaseSelectProps) {
const displayInSubMenu =
display === DisplayTypes.ICON
? DisplayTypes.LABEL
- : display === DisplayTypes.INPUT
+ : display === DisplayTypes.INPUT || display === DisplayTypes.FONT
? DisplayTypes.LABEL
: display;
@@ -706,7 +706,14 @@ export function Select(props: BaseSelectProps) {
display={display}
title={title!}
value={value}
+ max={max}
+ min={min}
onChange={(v) => onClick?.(v)}
+ onFocus={() => {
+ console.info(
+ 'TODO: 需要待Dropdown与Menu分离之后,直接控制Dropdown展示文字大小下拉选项'
+ );
+ }}
/>
</div>
</Dropdown>
diff --git a/packages/base-ui/src/Components/Select/index.module.css b/packages/base-ui/src/Components/Select/index.module.css
deleted file mode 100644
index a19d45450a..0000000000
--- a/packages/base-ui/src/Components/Select/index.module.css
+++ /dev/null
@@ -1,82 +0,0 @@
-.select-component {
- position: relative;
- margin: 0 3px;
- height: 26px;
-}
-.select-component:hover {
- background-color: var(--gray-14);
-}
-.select-component .select-button {
- padding: 0px 5px;
-}
-.select-component .select-button span[role='img'] {
- font-size: 24px;
-}
-.select-component .select-single {
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-.select-component .select-single:hover {
- background: var(--bg-hover);
-}
-.select-component .select-input {
- display: flex;
- align-items: center;
-}
-.select-component .select-input:hover {
- background: var(--bg-hover);
-}
-.select-component .select-input input {
- width: 38px;
- height: 20px;
- background: transparent;
- border: 1px solid transparent;
-}
-.select-component .select-input input::-webkit-outer-spin-button,
-.select-component .select-input input::-webkit-inner-spin-button {
- -webkit-appearance: none;
-}
-.select-component .select-input input[type='number'] {
- -moz-appearance: textfield;
-}
-.select-component .select-input input:hover {
- border: 1px solid transparent;
-}
-.select-component .select-input input:focus {
- background: #fff;
- border: 1px solid var(--primary-color-hover);
-}
-.select-component .select-double:hover {
- background: var(--bg-hover);
-}
-.select-component .select-double .dropdown {
- height: 24px;
- padding-right: 0;
-}
-.select-component .select-double .drop-content {
- position: relative;
-}
-.select-component .select-double .drop-content .select-line {
- position: absolute;
- width: 15px;
- height: 5px;
- background-color: #000;
- bottom: 0px;
- left: 50%;
- transform: translate(-50%, 0);
-}
-.select-component .select-double .drop-icon {
- border-left: 1px solid transparent;
-}
-.select-component .select-double:hover .drop-icon {
- border-left: 1px solid var(--gray-6);
-}
-.select-component .select-label span[role='img'] {
- font-size: 24px;
-}
-.select-component button {
- padding: 0px;
- box-sizing: border-box;
- border-color: transparent;
- height: auto;
-}
diff --git a/packages/base-ui/src/Components/Select/index.module.less b/packages/base-ui/src/Components/Select/index.module.less
index ba52b7726a..ce250a5d70 100644
--- a/packages/base-ui/src/Components/Select/index.module.less
+++ b/packages/base-ui/src/Components/Select/index.module.less
@@ -66,7 +66,6 @@
}
.dropdown {
- height: 24px;
padding-right: 0;
}
@@ -90,7 +89,8 @@
&:hover {
.drop-icon {
- border-left: 1px solid var(--gray-6);
+ // TODO: Use different background color to distinguish the hover state
+ // border-left: 1px solid var(--gray-6);// new design, no border
}
}
}
diff --git a/packages/base-ui/src/services/menu/menu.ts b/packages/base-ui/src/services/menu/menu.ts
index 08b9d2265a..dc3de4f367 100644
--- a/packages/base-ui/src/services/menu/menu.ts
+++ b/packages/base-ui/src/services/menu/menu.ts
@@ -50,6 +50,16 @@ interface IMenuItemBase<V> {
/** On observable value that should emit the value of the corresponding selection component. */
value$?: Observable<V>;
onClose?: () => void;
+
+ /**
+ * e.g. set cell text size, rotation angle of the text
+ */
+ max?: number;
+
+ /**
+ * Set the minimum value of the digital input box
+ */
+ min?: number;
}
export interface IMenuButtonItem<V = undefined> extends IMenuItemBase<V> {
diff --git a/packages/base-ui/src/views/components/contextmenu/contextmenu.module.less b/packages/base-ui/src/views/components/contextmenu/contextmenu.module.less
index 68a974918e..a773039e88 100644
--- a/packages/base-ui/src/views/components/contextmenu/contextmenu.module.less
+++ b/packages/base-ui/src/views/components/contextmenu/contextmenu.module.less
@@ -12,7 +12,7 @@
.cols-menu {
.cols-menuitem {
text-align: left;
- padding: 6px 25px 6px 25px;
+ padding: 8px 24px 8px 4px;
input {
width: 40px;
diff --git a/packages/base-ui/src/views/components/toolbar/toolbar-item.tsx b/packages/base-ui/src/views/components/toolbar/toolbar-item.tsx
index 52033e6284..ccc3f535b7 100644
--- a/packages/base-ui/src/views/components/toolbar/toolbar-item.tsx
+++ b/packages/base-ui/src/views/components/toolbar/toolbar-item.tsx
@@ -88,7 +88,7 @@ export class ToolbarItem extends Component<IDisplayMenuItem<IMenuItem>, IToolbar
const { disabled, value } = state;
const props = this.props as IDisplayMenuItem<IMenuSelectorItem>;
- const { icon, title, label, display, selectType, selections, id, onClose } = props;
+ const { icon, title, label, display, selectType, selections, id, onClose, max, min } = props;
return (
<Tooltip title={this.getTooltip()} placement="bottom">
@@ -101,6 +101,8 @@ export class ToolbarItem extends Component<IDisplayMenuItem<IMenuItem>, IToolbar
icon={icon}
value={value}
label={value ?? label} // TODO: this line is strange
+ max={max}
+ min={min}
onClick={(value) => {
// commandService.executeCommand(id, { value })
// 子元素commandId会被现在的id覆盖,暂时这么写以区分
@@ -108,12 +110,9 @@ export class ToolbarItem extends Component<IDisplayMenuItem<IMenuItem>, IToolbar
if (value instanceof Object && value.id) {
commandId = value.id;
}
- commandService.executeCommand(commandId, value);
- }} // TODO@wzhudev: should be merged to a single API on value change
- onPressEnter={(value) => {
- let commandId = id;
- if (value instanceof Object && value.id) {
- commandId = value.id;
+
+ if (typeof value === 'string') {
+ value = { value };
}
commandService.executeCommand(commandId, value);
}}
diff --git a/packages/sheets-plugin-find/src/View/UI/FindModal.tsx b/packages/sheets-plugin-find/src/View/UI/FindModal.tsx
index 35f8c49c9b..495e285a77 100644
--- a/packages/sheets-plugin-find/src/View/UI/FindModal.tsx
+++ b/packages/sheets-plugin-find/src/View/UI/FindModal.tsx
@@ -219,7 +219,7 @@ export class FindModal extends Component<IProps, IState> {
<CustomLabel label="find.find" />
</span>
)}
- <Input onPressEnter={this.findNext.bind(this)} onChange={(e) => this.onChange(e)}></Input>
+ <Input onValueChange={this.findNext.bind(this)} onChange={(e) => this.onChange(e)}></Input>
{count ? (
<div className={styles.count}>
<span onClick={this.findPrevious.bind(this)}>
diff --git a/packages/ui-plugin-sheets/src/View/RightMenu/RightMenuInput.tsx b/packages/ui-plugin-sheets/src/View/RightMenu/RightMenuInput.tsx
index 5bc0965be6..773cddb618 100644
--- a/packages/ui-plugin-sheets/src/View/RightMenu/RightMenuInput.tsx
+++ b/packages/ui-plugin-sheets/src/View/RightMenu/RightMenuInput.tsx
@@ -4,10 +4,14 @@ import React, { useEffect, useState } from 'react';
interface IProps extends ICustomComponentProps<string> {
prefix: string;
suffix: string;
- onKeyUp?: (e: Event) => void;
+
+ /**
+ * After ENTER, execute Command, close the right-click menu
+ */
+ onValueChange?: (value: string) => void;
}
-export const RightMenuInput: React.FC<IProps> = ({ prefix, suffix, value, onChange }) => {
+export const RightMenuInput: React.FC<IProps> = ({ prefix, suffix, value, onChange, onValueChange }) => {
const [inputValue, setInputValue] = useState<string>(); // Initialized to an empty string
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
@@ -29,6 +33,7 @@ export const RightMenuInput: React.FC<IProps> = ({ prefix, suffix, value, onChan
value={inputValue}
onClick={(e) => e.stopPropagation()}
onChange={handleChange}
+ onValueChange={onValueChange}
></Input>
<CustomLabel label={suffix} />
</div>
diff --git a/packages/ui-plugin-sheets/src/View/RightMenu/index.module.less b/packages/ui-plugin-sheets/src/View/RightMenu/index.module.less
index b3ec63c15c..5ec110d899 100644
--- a/packages/ui-plugin-sheets/src/View/RightMenu/index.module.less
+++ b/packages/ui-plugin-sheets/src/View/RightMenu/index.module.less
@@ -10,7 +10,7 @@
.cols-menu {
.cols-menuitem {
text-align: left;
- padding: 6px 25px 6px 25px;
+ padding: 8px 24px 8px 4px;
input {
width: 40px;
diff --git a/packages/ui-plugin-sheets/src/controller/menu/menu.ts b/packages/ui-plugin-sheets/src/controller/menu/menu.ts
index 4bce03a77f..9dce0a93ce 100644
--- a/packages/ui-plugin-sheets/src/controller/menu/menu.ts
+++ b/packages/ui-plugin-sheets/src/controller/menu/menu.ts
@@ -383,7 +383,6 @@ export const FONT_FAMILY_CHILDREN = [
label: 'fontFamily.TimesNewRoman',
style: { 'font-family': 'Times New Roman' },
value: 'Times New Roman',
- selected: true,
},
{
label: 'fontFamily.Arial',
@@ -533,6 +532,8 @@ export function FontSizeSelectorMenuItemFactory(accessor: IAccessor): IMenuSelec
type: MenuItemType.SELECTOR,
selectType: SelectTypes.NEO,
display: DisplayTypes.INPUT,
+ min: 1,
+ max: 400,
positions: [MenuPosition.TOOLBAR],
selections: FONT_SIZE_CHILDREN,
disabled$: new Observable<boolean>((subscriber) => {