-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Shared UX] Migrate popover from presentation to shared ux package #128665
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pretty sound to me, but @clintandrewhall if you could have an additional look, would be appreciated.
@@ -9,14 +9,16 @@ | |||
import React from 'react'; | |||
import { EuiButton } from '@elastic/eui'; | |||
import { EuiButtonPropsForButton } from '@elastic/eui/src/components/button/button'; | |||
import { ButtonContentIconSide } from '@elastic/eui/src/components/button/button_content'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { ButtonContentIconSide } from '@elastic/eui/src/components/button/button_content'; | |
import { EuiButtonDisplayProps } from '@elastic/eui/src/components/button/button_content'; |
|
||
export interface Props extends Pick<EuiButtonPropsForButton, 'onClick' | 'iconType'> { | ||
label: string; | ||
iconSide?: ButtonContentIconSide; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iconSide?: ButtonContentIconSide; |
@@ -9,14 +9,16 @@ | |||
import React from 'react'; | |||
import { EuiButton } from '@elastic/eui'; | |||
import { EuiButtonPropsForButton } from '@elastic/eui/src/components/button/button'; | |||
import { ButtonContentIconSide } from '@elastic/eui/src/components/button/button_content'; | |||
|
|||
export interface Props extends Pick<EuiButtonPropsForButton, 'onClick' | 'iconType'> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export interface Props extends Pick<EuiButtonPropsForButton, 'onClick' | 'iconType'> { | |
export interface Props extends Pick<EuiButtonPropsForButton, 'onClick' | 'iconType' | 'iconSide'> { |
return ( | ||
<EuiButton size="m" color="primary" fill={true} {...rest}> | ||
<EuiButton size="m" color="primary" fill={true} iconSide={iconSide} {...rest}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is necessary, but it it is:
<EuiButton size="m" color="primary" fill={true} iconSide={iconSide} {...rest}> | |
<EuiButton size="m" color="primary" fill={true} {...{ iconSide, ...rest }> |
const button = <ToolbarButton onClick={onButtonClick} {...{ label, iconSide, iconType }} />; | ||
|
||
return ( | ||
// @ts-ignore - Types of property csss are incompatible Type 'InterpolationWithTheme<any>' is not assignable to type 'Interpolation<Theme>'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thompsongl Any suggestions on this particular error?
// @ts-ignore - Types of property csss are incompatible Type 'InterpolationWithTheme<any>' is not assignable to type 'Interpolation<Theme>'. | |
// @ts-expect-error - Types of property css are incompatible Type 'InterpolationWithTheme<any>' is not assignable to type 'Interpolation<Theme>'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My guess is this was a leftover from some previous version of EUI. I removed it now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, by removing it I get the following error:
Type '{ children: ReactNode; onClick?: MouseEventHandler<HTMLDivElement> \| undefined; color?: string \| undefined; style?: CSSProperties \| undefined; ... 276 more ...; closePopover: () => void; }' is not assignable to type 'IntrinsicClassAttributes<EuiPopover>'.
--
| info [bazel] Types of property 'css' are incompatible.
| info [bazel] Type 'InterpolationWithTheme<any>' is not assignable to type 'Interpolation<Theme>'.
| info [bazel] Type 'ArrayInterpolation<undefined>' is not assignable to type 'Interpolation<Theme>'.
| info [bazel] Type 'ArrayInterpolation<undefined>' is not assignable to type 'ArrayInterpolation<Theme>'.
| info [bazel] The types returned by 'pop()' are incompatible between these types.
| info [bazel] Type 'Interpolation<undefined>' is not assignable to type 'Interpolation<Theme>'.
| info [bazel] Type 'ArrayInterpolation<undefined>' is not assignable to type 'Interpolation<Theme>'.
| info [bazel]
| info [bazel] 35 <EuiPopover {...{ isOpen, button, closePopover }} {...popover}>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, just saw you were talking about ts-ignore
vs ts-expect-error
rather than the actual type error not being present :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify, I don't get any errors after removing the TS comment entirely. bazel build
and type_check
both pass, and I get no errors in my IDE. Where do you see that error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see it now on bootstrap. That error is from a type mismatch between emotion@10 and emotion@11. Storybook uses emotion@10 and EUI, Kibana, etc. use emotion@11. This is more likely a bazel config problem (perhaps from how it builds with kbn-storybook
package?) more so than an actual type error. Thinking on how to resolve.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding the following to kbn-shared-ux-components/tsconfig.json
compilerOptions
resolves the error:
"paths": {
"@emotion/core": [
"node_modules/@emotion/react"
]
}
Also, the error will be resolved for us in the next release of storybook: https://github.com/storybookjs/storybook/releases/tag/v6.5.0-alpha.31
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to take the fix provided by @thompsongl for the Typescript incompatibility.
const button = <ToolbarButton onClick={onButtonClick} {...{ label, iconSide, iconType }} />; | ||
|
||
return ( | ||
// @ts-ignore - Types of property css are incompatible Type 'InterpolationWithTheme<any>' is not assignable to type 'Interpolation<Theme>'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should rarely-- if ever-- use @ts-ignore
, because if the error is resolved elsewhere, the ignore will remain. If we use @ts-expect-error
, changes that resolve the error will prompt the resolver to remove this comment.
// @ts-ignore - Types of property css are incompatible Type 'InterpolationWithTheme<any>' is not assignable to type 'Interpolation<Theme>'. | |
// @ts-expect-error - Types of property css are incompatible Type 'InterpolationWithTheme<any>' is not assignable to type 'Interpolation<Theme>'. |
@elasticmachine merge upstream |
expected head sha didn’t match current head ref. |
@elasticmachine merge upstream |
Synced offline with @spalger about the ts problem, this is the conclusion:
|
@elasticmachine merge upstream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please complete my two documentation requests before committing. Approving to unblock.
date: 2022-03-28 | ||
--- | ||
|
||
> This documentation is in-progress. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to complete this before committing.
const button = <ToolbarButton onClick={onButtonClick} {...{ label, iconSide, iconType }} />; | ||
|
||
return ( | ||
// @ts-ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a comment before committing.
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]Module Count
Public APIs missing comments
Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: cc @rshen91 |
Summary
This PR migrates the popover from the items directory in presentation_util to the shared ux package.
The ToolbarButton is refactored to accept a specified
iconSide
prop to accommodate controls such ascontrol_group_container.tsx
where the icon is on the right.ts-ignore comment added to bypass the error:
Checklist