`;
-exports[`renders components/sender/demo/submitType.tsx correctly 1`] = `
+exports[`renders components/sender/demo/basic.tsx correctly 1`] = `
-
+
+
+
+
+
+
+
+
+
+
+
`;
+
+exports[`renders components/sender/demo/send-style.tsx correctly 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`renders components/sender/demo/submitType.tsx correctly 1`] = `
+
+`;
diff --git a/components/sender/__tests__/__snapshots__/index.test.tsx.snap b/components/sender/__tests__/__snapshots__/index.test.tsx.snap
index af265867..0a00230f 100644
--- a/components/sender/__tests__/__snapshots__/index.test.tsx.snap
+++ b/components/sender/__tests__/__snapshots__/index.test.tsx.snap
@@ -6,49 +6,68 @@ exports[`Sender Component loading state 1`] = `
class="ant-sender"
>
-
-
-
+
+
+
+
@@ -60,87 +79,43 @@ exports[`Sender Component rtl render component should be rendered correctly in R
class="ant-sender css-var-r1 ant-sender-rtl"
>
-
-
-
-
-
-
+
+
diff --git a/components/sender/__tests__/index.test.tsx b/components/sender/__tests__/index.test.tsx
index 0bef2928..1190aa60 100644
--- a/components/sender/__tests__/index.test.tsx
+++ b/components/sender/__tests__/index.test.tsx
@@ -1,9 +1,9 @@
import React from 'react';
+import { fireEvent, render } from '@testing-library/react';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
import Sender from '../index';
-import { fireEvent, render } from '@testing-library/react';
describe('Sender Component', () => {
mountTest(() =>
);
@@ -61,20 +61,25 @@ describe('Sender Component', () => {
it('onSubmit', () => {
const onSubmit = jest.fn();
const { container } = render(
);
- fireEvent.click(container.querySelectorAll('button')[1]);
+ fireEvent.click(container.querySelector('button')!);
expect(onSubmit).toHaveBeenCalledWith('bamboo');
});
it('onCancel', () => {
const onCancel = jest.fn();
const { container } = render(
);
- fireEvent.click(container.querySelectorAll('button')[1]);
+ fireEvent.click(container.querySelector('button')!);
expect(onCancel).toHaveBeenCalled();
});
it('onClear', () => {
const onChange = jest.fn();
- const { container } = render(
);
+ const { container } = render(
+
}
+ />,
+ );
fireEvent.change(container.querySelector('textarea')!, { target: { value: 'bamboo' } });
expect(onChange).toHaveBeenCalledWith('bamboo');
diff --git a/components/sender/components/ActionButton.tsx b/components/sender/components/ActionButton.tsx
index 8851309d..2c3f30d3 100644
--- a/components/sender/components/ActionButton.tsx
+++ b/components/sender/components/ActionButton.tsx
@@ -10,6 +10,7 @@ export interface ActionButtonContextProps {
onClearDisabled?: boolean;
onCancel?: VoidFunction;
onCancelDisabled?: boolean;
+ disabled?: boolean;
}
export const ActionButtonContext = React.createContext(null!);
@@ -18,26 +19,34 @@ export interface ActionButtonProps extends ButtonProps {
action: 'onSend' | 'onClear' | 'onCancel';
}
-export default function ActionButton(props: ActionButtonProps) {
+export function ActionButton(props: ActionButtonProps, ref: React.Ref) {
const { className, action, onClick: outClick, ...restProps } = props;
const context = React.useContext(ActionButtonContext);
+ const { prefixCls, disabled: rootDisabled } = context;
const onClick = context[action];
- const disabled = context[`${action}Disabled`];
+ const mergedDisabled = rootDisabled ?? restProps.disabled ?? context[`${action}Disabled`];
+
return (
diff --git a/components/useXChat/__tests__/__snapshots__/demo.test.ts.snap b/components/useXChat/__tests__/__snapshots__/demo.test.ts.snap
index 184826b5..258ab4e4 100644
--- a/components/useXChat/__tests__/__snapshots__/demo.test.ts.snap
+++ b/components/useXChat/__tests__/__snapshots__/demo.test.ts.snap
@@ -12,86 +12,42 @@ exports[`renders components/useXChat/demo/basic.tsx correctly 1`] = `
class="ant-sender css-var-R0"
>