Skip to content

Commit

Permalink
Fix EuiPanel onClick def (#2330)
Browse files Browse the repository at this point in the history
* fix euipanel exclusiveunion

* CL
  • Loading branch information
thompsongl authored Sep 11, 2019
1 parent c56ca2c commit 330f0e0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
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

0 comments on commit 330f0e0

Please sign in to comment.