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

EuiSuperDatePicker should show tooltip for the popover close event #3127

Merged
merged 13 commits into from
Mar 23, 2020
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Improved `EuiButtonEmpty` focus state when the `color` type is `text` ([#3135](https://github.com/elastic/eui/pull/3135))
- Added `EuiLoadingElastic` component ([#3017](https://github.com/elastic/eui/pull/3017))
- Upgraded `react-beautiful-dnd` to v13 ([#3064](https://github.com/elastic/eui/pull/3064))
- Added `showTooltip` prop for `EuiSuperUpdateButton` to show tooltip and showing only once popovers are closed ([#3127](https://github.com/elastic/eui/pull/3127))

**Bug Fixes**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ exports[`EuiSuperDatePicker is rendered 1`] = `
isLoading={false}
needsUpdate={false}
onClick={[Function]}
showTooltip={true}
/>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,30 @@ exports[`EuiSuperUpdateButton needsUpdate 1`] = `
</EuiButton>
</EuiToolTip>
`;

exports[`EuiSuperUpdateButton showTooltip 1`] = `
<EuiToolTip
delay="regular"
position="bottom"
>
<EuiButton
className="euiSuperUpdateButton"
color="primary"
fill={true}
iconType="refresh"
isDisabled={false}
isLoading={false}
onClick={[Function]}
textProps={
Object {
"className": "euiSuperUpdateButton__text",
}
}
>
<EuiI18n
default="Refresh"
token="euiSuperUpdateButton.refreshButtonLabel"
/>
</EuiButton>
</EuiToolTip>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,10 @@ export class EuiSuperDatePicker extends Component {
<EuiFlexItem grow={false}>
<EuiSuperUpdateButton
needsUpdate={this.state.hasChanged}
showTooltip={
!this.state.isStartDatePopoverOpen &&
!this.state.isEndDatePopoverOpen
}
isLoading={this.props.isLoading}
isDisabled={this.props.isDisabled || this.state.isInvalid}
onClick={this.handleClickUpdateButton}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,23 @@ export class EuiSuperUpdateButton extends Component {
isLoading: PropTypes.bool,
isDisabled: PropTypes.bool,
onClick: PropTypes.func.isRequired,

/**
* Passes props to `EuiToolTip`
*/
toolTipProps: PropTypes.object,

/**
* Show the "Click to apply" tooltip
*/
showTooltip: PropTypes.bool,
};

static defaultProps = {
needsUpdate: false,
isLoading: false,
isDisabled: false,
showTooltip: false,
};

componentWillUnmount() {
Expand All @@ -34,7 +41,7 @@ export class EuiSuperUpdateButton extends Component {

componentDidUpdate() {
if (
this.props.needsUpdate &&
this.props.showTooltip &&
!this.props.isDisabled &&
!this.props.isLoading
) {
Expand Down Expand Up @@ -69,6 +76,7 @@ export class EuiSuperUpdateButton extends Component {
isDisabled,
onClick,
toolTipProps,
showTooltip,
...rest
} = this.props;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,12 @@ describe('EuiSuperUpdateButton', () => {

expect(component).toMatchSnapshot();
});

test('showTooltip', () => {
const component = shallow(
<EuiSuperUpdateButton showTooltip onClick={noop} />
);

expect(component).toMatchSnapshot();
});
});