Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion components/alert/src/alert-bar/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import React, { Component } from 'react'
class Action extends Component {
onClick = (event) => {
this.props.onClick(event)
this.props.hide(event)
if (this.props.hideOnClick) {
this.props.hide(event)
}
}

render() {
Expand All @@ -26,9 +28,14 @@ class Action extends Component {
}
}

Action.defaultProps = {
hideOnClick: true
}

Action.propTypes = {
dataTest: PropTypes.string.isRequired,
hide: PropTypes.func.isRequired,
hideOnClick: PropTypes.boolean.isRequired,
label: PropTypes.string.isRequired,
onClick: PropTypes.func.isRequired,
}
Expand Down
7 changes: 5 additions & 2 deletions components/alert/src/alert-bar/alert-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const AlertBar = ({
hidden,
icon,
permanent,
dismissable,
success,
warning,
onHidden,
Expand Down Expand Up @@ -127,10 +128,10 @@ const AlertBar = ({
hide={runHideAnimation}
dataTest={dataTest}
/>
<Dismiss
{dismissable && <Dismiss
onClick={runHideAnimation}
dataTest={`${dataTest}-dismiss`}
/>
/>}

<style jsx>{styles}</style>
</div>
Expand All @@ -146,6 +147,7 @@ AlertBar.defaultProps = {
duration: 8000,
dataTest: 'dhis2-uicore-alertbar',
icon: true,
dismissable: true,
}

AlertBar.propTypes = {
Expand All @@ -165,6 +167,7 @@ AlertBar.propTypes = {
*/
icon: iconPropType,
permanent: PropTypes.bool,
dismissable: PropTypes.bool,
success: alertTypePropType,
/** Alert bars with `warning` will not autohide */
warning: alertTypePropType,
Expand Down