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

[EuiPopover] Added panelProps prop #4573

Merged
merged 13 commits into from
Mar 3, 2021
Merged

Conversation

akashgp09
Copy link
Contributor

@akashgp09 akashgp09 commented Feb 24, 2021

Summary

This PR Fixes: #4293

Added panelProps prop to EuiPopover

Checklist

  • Check against all themes for compatibility in both light and dark modes
  • Checked in mobile
  • Checked in Chrome, Edge, and Firefox
  • Props have proper autodocs and playground toggles
    - [ ] Added documentation
    - [ ] Checked Code Sandbox works for the any docs examples
  • Added or updated jest tests
    - [ ] Checked for breaking changes and labeled appropriately
    - [ ] Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

@kibanamachine
Copy link

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@myasonik
Copy link
Contributor

myasonik commented Feb 24, 2021

Hey @akashgp09! Thanks for this PR but I think there was some confusion in the issue - EuiPanel shouldn't have gotten any new props because what we're hoping to do is pass in the props it already supports through EuiPopover.

I'll try to explain at a high level what we're looking for here and hopefull that clears it up!

So, in src/components/popover/popover.tsx, panelProps should be of type EuiPanelProps.

And then instead of passing passing in <EuiPanel panelProps={panelProps} /> like you're doing, we can spread all the props into the panel like so <EuiPanel {...panelProps} />. It's important for this to be the last property passed in so that these props can serve as an override for anything already set.

@akashgp09
Copy link
Contributor Author

akashgp09 commented Feb 24, 2021

@myasonik thanks for the review, now it's clear to me ^_^. I will make the changes soon .

@myasonik
Copy link
Contributor

jenkins test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4573/

@akashgp09 akashgp09 changed the title [EuiPopover,EuiPanel] Added panelProps prop [EuiPopover] Added panelProps prop Feb 25, 2021
Copy link
Contributor

@myasonik myasonik left a comment

Choose a reason for hiding this comment

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

This LGTM!

Will let an EUI team member review/merge.

@@ -143,7 +143,6 @@ export const EuiPanel: FunctionComponent<EuiPanelProps> = ({
// Shadows are only allowed when there's a white background (plain)
const canHaveShadow = color === 'plain';
const canHaveBorder = color === 'plain' || color === 'transparent';

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you just revert all changes to this file?

Comment on lines 775 to 776
style={this.state.popoverStyles}
{...panelProps}>
Copy link
Contributor

@cchaos cchaos Feb 25, 2021

Choose a reason for hiding this comment

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

The only thing about putting this prop at the bottom is that now the user can override any of the props including ones that are absolutely necessary for it display or behave well with a11y. Instead this prop should live at the top of this list and then in the state.popoverStyles account for any possible panelProps?.style and in the panelClasses, add panelProps?.className since these are allowed to be extended but we don't want the user completely overriding the internals.

@akashgp09 akashgp09 requested a review from cchaos February 25, 2021 20:26
@@ -767,7 +774,7 @@ export class EuiPopover extends Component<Props, State> {
aria-labelledby={ariaLabelledBy}
aria-modal="true"
aria-describedby={ariaDescribedby}
style={this.state.popoverStyles}>
style={panelProps?.style || this.state.popoverStyles}>
Copy link
Contributor

@cchaos cchaos Feb 25, 2021

Choose a reason for hiding this comment

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

Sorry this one isn't an or situation. Wherever the state.popoverStyles is being set, you'll need to also add panelProps?.style.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

got it 👍

@akashgp09 akashgp09 requested a review from cchaos February 25, 2021 22:10
@cchaos
Copy link
Contributor

cchaos commented Feb 25, 2021

Jenkins, test this

@myasonik
Copy link
Contributor

Looks like a type error - not sure how to resolve it from the top of my head

src/components/popover/popover.tsx(764,14): error TS2322: Type '{ children: (Element | undefined)[]; panelRef: (node: HTMLElement | null) => void; className: string; hasShadow: false; paddingSize: "none" | "s" | "m" | "l" | undefined; ... 269 more ...; betaBadgeTitle?: string | undefined; }' is not assignable to type '(IntrinsicAttributes & DisambiguateSet<Divlike, Buttonlike> & Buttonlike & { children?: ReactNode; }) | (IntrinsicAttributes & ... 2 more ... & { ...; })'.
22:41:56   Type '{ children: (Element | undefined)[]; panelRef: (node: HTMLElement | null) => void; className: string; hasShadow: false; paddingSize: "none" | "s" | "m" | "l" | undefined; ... 269 more ...; betaBadgeTitle?: string | undefined; }' is not assignable to type 'Buttonlike'.
22:41:56     Types of property 'onCopy' are incompatible.
22:41:56       Type '((event: ClipboardEvent<HTMLButtonElement>) => void) | ((event: ClipboardEvent<HTMLDivElement>) => void) | undefined' is not assignable to type '((event: ClipboardEvent<HTMLButtonElement>) => void) | undefined'.
22:41:56         Type '(event: ClipboardEvent<HTMLDivElement>) => void' is not assignable to type '(event: ClipboardEvent<HTMLButtonElement>) => void'.
22:41:56           Types of parameters 'event' and 'event' are incompatible.
22:41:56             Type 'ClipboardEvent<HTMLButtonElement>' is not assignable to type 'ClipboardEvent<HTMLDivElement>'.
22:41:56               Property 'align' is missing in type 'HTMLButtonElement' but required in type 'HTMLDivElement'.

@@ -756,6 +762,7 @@ export class EuiPopover extends Component<Props, State> {
!ownFocus || !this.state.isOpenStable || this.state.isClosing
}>
<EuiPanel
{...panelProps}
Copy link
Contributor

Choose a reason for hiding this comment

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

Passing {...(panelProps as EuiPanelProps)} here will resolve the TypeScript issue mentioned in #4573 (comment) - somewhere between accepting panelProps and forwarding it here TS forgets the value has been validated and appears to intersect the div & button props.

src/components/popover/popover.tsx Show resolved Hide resolved
@akashgp09
Copy link
Contributor Author

@cchaos @chandlerprall i have made the changes as suggested. Please let me know if there are any changes required.

@cchaos
Copy link
Contributor

cchaos commented Mar 1, 2021

Jenkins, test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4573/

Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

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

👍 Changes look good to me. @chandlerprall Let us know if you're good with the panelProps.style handling.

@cchaos
Copy link
Contributor

cchaos commented Mar 3, 2021

I'm gonna get this merged in. We can consider deprecating those other props later, but I know they're widely used so this new prop is mostly a ...rest.

Jenkins, test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4573/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[EuiPopover] has no way to pass data-test-subj to panel
5 participants