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

Fix EuiPanel onClick def #2330

Merged
merged 2 commits into from
Sep 11, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
**Bug fixes**

- Corrected `EuiCodeBlock`'s proptype for `children` to be string or array of strings. ([#2324](https://github.com/elastic/eui/pull/2324))
- Fixed `onClick` TypeScript definition for `EuiPanel` ([#2330](https://github.com/elastic/eui/pull/2330))

## [`13.8.1`](https://github.com/elastic/eui/tree/v13.8.1)

Expand Down
21 changes: 12 additions & 9 deletions src/components/panel/panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, {
ButtonHTMLAttributes,
FunctionComponent,
HTMLAttributes,
MouseEventHandler,
ReactNode,
Ref,
} from 'react';
Expand All @@ -13,7 +12,7 @@ import { EuiBetaBadge } from '../badge/beta_badge';

export type PanelPaddingSize = 'none' | 's' | 'm' | 'l';

export interface EuiPanelProps {
export interface EuiPanelProps extends CommonProps {
/**
* If active, adds a deeper shadow to the panel
*/
Expand Down Expand Up @@ -45,13 +44,15 @@ export interface EuiPanelProps {
betaBadgeTitle?: string;
}

type Divlike = Omit<HTMLAttributes<HTMLDivElement>, 'onClick'>;
interface Divlike
extends EuiPanelProps,
Omit<HTMLAttributes<HTMLDivElement>, 'onClick'> {}

interface Buttonlike {
onClick?: MouseEventHandler<HTMLButtonElement>;
}
interface Buttonlike
extends EuiPanelProps,
ButtonHTMLAttributes<HTMLButtonElement> {}

type Props = CommonProps & EuiPanelProps & ExclusiveUnion<Divlike, Buttonlike>;
type Props = ExclusiveUnion<Divlike, Buttonlike>;

const paddingSizeToClassNameMap = {
none: null,
Expand Down Expand Up @@ -115,8 +116,10 @@ export const EuiPanel: FunctionComponent<Props> = ({
}

return (
// ts-ignore seems to be some div / button confusion here
<div ref={panelRef} className={classes} {...rest}>
<div
ref={panelRef as Ref<HTMLDivElement>}
className={classes}
{...rest as HTMLAttributes<HTMLDivElement>}>
{optionalBetaBadge}
{children}
</div>
Expand Down