Skip to content

Commit

Permalink
[core] feat(Text): allow passing HTML props (#4798)
Browse files Browse the repository at this point in the history
  • Loading branch information
invliD authored Jul 7, 2021
1 parent 01d2d77 commit 9be03db
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions packages/core/src/components/text/text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ export interface ITextState {
}

@polyfill
export class Text extends AbstractPureComponent2<TextProps, ITextState> {
export class Text extends AbstractPureComponent2<
TextProps & Omit<React.HTMLAttributes<HTMLElement>, "title">,
ITextState
> {
public static displayName = `${DISPLAYNAME_PREFIX}.Text`;

public static defaultProps: Partial<TextProps> = {
ellipsize: false,
tagName: "div",
};

public state: ITextState = {
Expand All @@ -76,17 +78,15 @@ export class Text extends AbstractPureComponent2<TextProps, ITextState> {
}

public render() {
const classes = classNames(
{
[Classes.TEXT_OVERFLOW_ELLIPSIS]: this.props.ellipsize,
},
this.props.className,
);
const { children, tagName, title } = this.props;
const { children, className, ellipsize, tagName = "div", title, ...htmlProps } = this.props;
const classes = classNames(className, {
[Classes.TEXT_OVERFLOW_ELLIPSIS]: ellipsize,
});

return React.createElement(
tagName!,
tagName,
{
...htmlProps,
className: classes,
ref: (ref: HTMLElement | null) => (this.textRef = ref),
title: title ?? (this.state.isContentOverflowing ? this.state.textContent : undefined),
Expand Down

1 comment on commit 9be03db

@blueprint-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[core] feat(Text): allow passing HTML props (#4798)

Previews: documentation | landing | table

Please sign in to comment.