Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EuiStat title and description should allow ReactNode #1910

Merged
merged 3 commits into from
May 2, 2019
Merged
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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## [`master`](https://github.com/elastic/eui/tree/master)

No public interface changes since `10.3.0`.
**Bug fixes**

- Fixed a regression where `EuiStat` reported accepting `string` for `title`, `description`, even though `ReactNode` is acceptable ([#1910](https://github.com/elastic/eui/pull/1910))

## [`10.3.0`](https://github.com/elastic/eui/tree/v10.3.0)

Expand Down
14 changes: 10 additions & 4 deletions src/components/stat/stat.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import React, { Fragment, HTMLAttributes, FunctionComponent } from 'react';
import React, {
Fragment,
HTMLAttributes,
FunctionComponent,
ReactNode,
} from 'react';
import { CommonProps, keysOf } from '../common';
import classNames from 'classnames';

import { EuiText } from '../text';
import { EuiTitle, EuiTitleSize } from '../title/title';
import { EuiI18n } from '../i18n';
import makeId from '../form/form_row/make_id';
import { Omit } from '../common';

const colorToClassNameMap = {
default: null,
Expand All @@ -30,7 +36,7 @@ export interface EuiStatProps {
/**
* Set the description (label) text
*/
description: string;
description: ReactNode;
/**
* Will hide the title with an animation until false
*/
Expand All @@ -43,7 +49,7 @@ export interface EuiStatProps {
/**
* The (value) text
*/
title: string;
title: ReactNode;
Copy link
Contributor

Choose a reason for hiding this comment

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

With this change I get errors in cloud-ui lint related to a type collision with HTMLDivElement, which expects title to be a string.

So let's do this on L62

export const EuiStat: FunctionComponent<
  CommonProps & Omit<HTMLAttributes<HTMLDivElement>, 'title'> & EuiStatProps
>

after importing Omit from ../common

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good news: fixed, bad news: accidentally pushed f43e98d to master.

/**
* The color of the title text
*/
Expand All @@ -55,7 +61,7 @@ export interface EuiStatProps {
}

export const EuiStat: FunctionComponent<
CommonProps & HTMLAttributes<HTMLDivElement> & EuiStatProps
CommonProps & Omit<HTMLAttributes<HTMLDivElement>, 'title'> & EuiStatProps
> = ({
children,
className,
Expand Down