Ellipsis onExpand function takes event parameter (#22092)

This commit is contained in:
Blaz Pocrnja 2020-03-10 21:11:25 -06:00 committed by GitHub
parent 145f72741b
commit c8f437ea02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -40,7 +40,7 @@ interface EllipsisConfig {
rows?: number;
expandable?: boolean;
suffix?: string;
onExpand?: () => void;
onExpand?: React.MouseEventHandler<HTMLElement>;
}
export interface BlockProps extends TypographyProps {
@ -165,13 +165,13 @@ class Base extends React.Component<InternalBlockProps & ConfigConsumerProps, Bas
raf.cancel(this.rafId);
}
// =============== Expend ===============
onExpandClick = () => {
// =============== Expand ===============
onExpandClick: React.MouseEventHandler<HTMLElement> = e => {
const { onExpand } = this.getEllipsis();
this.setState({ expanded: true });
if (onExpand) {
onExpand();
(onExpand as React.MouseEventHandler<HTMLElement>)(e);
}
};

View File

@ -39,7 +39,7 @@ Basic text writing, including headings, body text, lists, and more.
| delete | Deleted line style | boolean | false | |
| disabled | Disabled content | boolean | false | |
| editable | Editable. Can control edit state when is object | boolean \| { editing: boolean, onStart: Function, onChange: Function(string) } | false | |
| ellipsis | Display ellipsis when text overflows. Can configure rows and expandable by using object | boolean \| { rows: number, expandable: boolean, onExpand: Function } | false | |
| ellipsis | Display ellipsis when text overflows. Can configure rows and expandable by using object | boolean \| { rows: number, expandable: boolean, onExpand: Function(event) } | false | |
| level | Set content importance. Match with `h1`, `h2`, `h3`, `h4` | number: `1`, `2`, `3`, `4` | 1 | |
| mark | Marked style | boolean | false | |
| underline | Underlined style | boolean | false | |
@ -55,7 +55,7 @@ Basic text writing, including headings, body text, lists, and more.
| delete | Deleted line style | boolean | false | |
| disabled | Disabled content | boolean | false | |
| editable | Editable. Can control edit state when is object | boolean \| { editing: boolean, onStart: Function, onChange: Function(string) } | false | |
| ellipsis | Display ellipsis when text overflows. Can configure rows expandable and suffix by using object | boolean \| { rows: number, expandable: boolean suffix: string, onExpand: Function } | false | |
| ellipsis | Display ellipsis when text overflows. Can configure rows expandable and suffix by using object | boolean \| { rows: number, expandable: boolean suffix: string, onExpand: Function(event) } | false | |
| mark | Marked style | boolean | false | |
| underline | Underlined style | boolean | false | |
| onChange | Trigger when user edits the content | Function(string) | - | |