Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions components/sender/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export interface SenderProps
actions?: React.ReactNode | ActionsRender;
allowSpeech?: AllowSpeech;
prefix?: React.ReactNode;
onlyInputFocus?: boolean;
footer?: React.ReactNode | FooterRender;
header?: React.ReactNode;
autoSize?: boolean | { minRows?: number; maxRows?: number };
Expand Down Expand Up @@ -124,6 +125,7 @@ const ForwardSender = React.forwardRef<SenderRef, SenderProps>((props, ref) => {
disabled,
allowSpeech,
prefix,
onlyInputFocus,
footer,
header,
onPaste,
Expand Down Expand Up @@ -266,6 +268,11 @@ const ForwardSender = React.forwardRef<SenderRef, SenderProps>((props, ref) => {
e.preventDefault();
}

if (onlyInputFocus && !(e.target as HTMLElement)?.closest(`.${inputCls}`)) {
e.preventDefault();
return;
}

inputRef.current?.focus();
};

Expand Down
1 change: 1 addition & 0 deletions components/sender/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ coverDark: https://mdn.alipayobjects.com/huamei_iwk9zp/afts/img/A*cOfrS4fVkOMAAA
| loading | 是否加载中 | boolean | false | - |
| header | 头部面板 | ReactNode | - | - |
| prefix | 前缀内容 | ReactNode | - | - |
| onlyInputFocus | 是否只有点击input的时候会获得聚焦 | boolean | false | - |
| footer | 底部内容 | ReactNode \| (info: { components: ActionsComponents }) => ReactNode | - | - |
| readOnly | 是否让输入框只读 | boolean | false | - |
| rootClassName | 根元素样式类 | string | - | - |
Expand Down