Skip to content

Commit

Permalink
Allow passing HTML props to Text component
Browse files Browse the repository at this point in the history
  • Loading branch information
invliD committed Jul 5, 2021
1 parent 5c05ce6 commit 476fb5a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/core/src/components/text/text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,11 @@ 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 +75,18 @@ export class Text extends AbstractPureComponent2<TextProps, ITextState> {
}

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

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 476fb5a

@blueprint-bot
Copy link

Choose a reason for hiding this comment

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

Allow passing HTML props to Text component

Previews: documentation | landing | table

Please sign in to comment.