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

allow for additional props on nonIdealState #5356

Closed
Closed
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
13 changes: 9 additions & 4 deletions packages/core/src/components/non-ideal-state/nonIdealState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import classNames from "classnames";
import * as React from "react";

import { AbstractPureComponent2 } from "../../common";
import { AbstractPureComponent2, removeNonHTMLProps } from "../../common";
import * as Classes from "../../common/classes";
import { DISPLAYNAME_PREFIX, MaybeElement, Props } from "../../common/props";
import { ensureElement } from "../../common/utils";
Expand All @@ -33,7 +33,7 @@ export enum NonIdealStateIconSize {
// eslint-disable-next-line deprecation/deprecation
export type NonIdealStateProps = INonIdealStateProps;
/** @deprecated use NonIdealStateProps */
export interface INonIdealStateProps extends Props {
export interface INonIdealStateProps extends Props, Omit<React.HTMLAttributes<HTMLDivElement>, "title"> {
/** An action to resolve the non-ideal state which appears after `description`. */
action?: JSX.Element;

Expand Down Expand Up @@ -79,10 +79,15 @@ export class NonIdealState extends AbstractPureComponent2<NonIdealStateProps> {
};

public render() {
const { action, children, className, layout } = this.props;
const { action, children, className, layout, ...restProps } = this.props;

const htmlProps = removeNonHTMLProps(restProps);

return (
<div className={classNames(Classes.NON_IDEAL_STATE, `${Classes.NON_IDEAL_STATE}-${layout}`, className)}>
<div
{...htmlProps}
className={classNames(Classes.NON_IDEAL_STATE, `${Classes.NON_IDEAL_STATE}-${layout}`, className)}
>
{this.maybeRenderVisual()}
{this.maybeRenderText()}
{action}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export class NonIdealStateExample extends React.PureComponent<IExampleProps, INo
description={this.state.showDescription ? description : undefined}
action={this.state.showAction ? action : undefined}
layout={this.state.layout}
role="alert"
Copy link
Contributor

@adidahiya adidahiya Jun 8, 2022

Choose a reason for hiding this comment

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

this example does not show an urgent, time-sensitive message, so this role is inappropriate.

to be honest I don't see any role in the list here which would be appropriate for a NonIdealState. so that begs the question, why are we adding this feature or demonstrating a <NonIdealState> example using the role attribute?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we can just cancel this PR

/>
</Example>
);
Expand Down