Skip to content

Commit

Permalink
ui: (fix) Tooltip component styling and props
Browse files Browse the repository at this point in the history
This fix is rework of previous changes related to PR:
#46557

Prior, to customize tooltip width for two particular cases,
changes were made in shared component and affected all tooltips
across project (tooltip width was set to 500px).

Instead of this, current changes keep component styles without
local changes and extend them with specific classes (via `overlayClassName`
prop). It allows to apply changes in specific places (Statements and Jobs
tables).

Next fix: the order of destructing props in `components/tooltip/tooltip.tsx`.
`{...props}` supplied as a last prop to `<AntTooltip />` component and it
overrides all previous props which have to be preserved. To fix this, ...props
was moved as first prop.

And last fix: Tooltips for Diagnostics Status Badge was set to be visible
always and with some random conditions tooltips appeared and were displayed
instantly. To fix this, `visible` prop was removed to trigger tooltip
visibility only on mouse hover.

And to position Diagnostics Status Badge tooltip more elegantly - it is
positioned to `bottomLeft` side, because this badge is displayed in the last
columns and there is not enough place on the right side for tooltip.

Release note (bug fix): Tooltips for statement diagnostics were shown always
instead of only on hover

Release justification: bug fixes and low-risk updates to new functionality
  • Loading branch information
koorosh committed Apr 1, 2020
1 parent 9c59059 commit a2dde8d
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 13 deletions.
2 changes: 0 additions & 2 deletions pkg/ui/src/components/tooltip/tooltip.styl
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
@require '~src/components/core/index.styl'

.tooltip-overlay
max-width max-content
.ant-tooltip-content
width 500px
.ant-tooltip-inner
@extend $text--body
line-height $line-height--small
Expand Down
6 changes: 3 additions & 3 deletions pkg/ui/src/components/tooltip/tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ export interface TooltipProps {
}

export function Tooltip(props: TooltipProps & AntTooltipProps) {
const { children, theme } = props;
const classes = cn("tooltip-overlay", `crl-tooltip--theme-${theme}`);
const { children, theme, overlayClassName } = props;
const classes = cn("tooltip-overlay", `crl-tooltip--theme-${theme}`, overlayClassName);
return (
<AntTooltip
{...props}
mouseEnterDelay={0.5}
overlayClassName={classes}
{...props}
>
{children}
</AntTooltip>
Expand Down
11 changes: 8 additions & 3 deletions pkg/ui/src/views/jobs/jobDescriptionCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,14 @@ export class JobDescriptionCell extends React.PureComponent<{ job: Job }> {
return (
<Link className={`${additionalStyle}`} to={`jobs/${String(job.id)}`}>
<div className="cl-table-link__tooltip">
<Tooltip arrowPointAtCenter placement="bottom" title={
<pre style={{whiteSpace: "pre-wrap"}} className="cl-table-link__description">{description}</pre>
}>
<Tooltip
arrowPointAtCenter
placement="bottom"
title={
<pre style={{whiteSpace: "pre-wrap"}} className="cl-table-link__description">{description}</pre>
}
overlayClassName="cl-table-link__statement-tooltip--fixed-width"
>
<div className="jobs-table__cell--description">{job.statement || job.description}</div>
</Tooltip>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,9 @@ export function DiagnosticStatusBadge(props: OwnProps) {

return (
<Tooltip
visible={enableTooltip}
title={tooltipContent}
theme="blue"
placement="bottom"
placement="bottomLeft"
>
<div
className="diagnostic-status-badge__content"
Expand Down
5 changes: 5 additions & 0 deletions pkg/ui/src/views/statements/statements.styl
Original file line number Diff line number Diff line change
Expand Up @@ -415,3 +415,8 @@ $plan-node-attribute-key-color = #37a806 // light green
text-decoration underline
._text-bold
font-family RobotoMono-Bold

.cl-table-link__statement-tooltip--fixed-width
max-width max-content
.ant-tooltip-content
max-width 500px
10 changes: 7 additions & 3 deletions pkg/ui/src/views/statements/statementsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,13 @@ function StatementLink(props: { statement: string, app: string, implicitTxn: boo
return (
<Link to={ `${base}/${encodeURIComponent(props.statement)}` }>
<div className="cl-table-link__tooltip">
<Tooltip placement="bottom" title={
<pre className="cl-table-link__description">{ getHighlightedText(props.statement, props.search) }</pre>
}>
<Tooltip
placement="bottom"
title={<pre className="cl-table-link__description">
{ getHighlightedText(props.statement, props.search) }
</pre>}
overlayClassName="cl-table-link__statement-tooltip--fixed-width"
>
<div className="cl-table-link__tooltip-hover-area">
{ getHighlightedText(shortStatement(summary, props.statement), props.search, true) }
</div>
Expand Down

0 comments on commit a2dde8d

Please sign in to comment.