Skip to content
Open
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- new icons:
- `state-confirmed-all`
- `state-declined-all`
- `<CardActions />`
- `preventEvents` property: Prevents events related to button clicks from bubbling up. Make this by default true in `<SimpleDialog />`

### Fixed

Expand Down
21 changes: 20 additions & 1 deletion src/components/Card/CardActions.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, {DOMAttributes} from "react";

import { CLASSPREFIX as eccgui } from "../../configuration/constants";

Expand All @@ -12,6 +12,13 @@ export interface CardActionsProps extends React.HTMLAttributes<HTMLDivElement> {
* Set footer to display its children on only one line.
*/
noWrap?: boolean;

/** Prevents all events related to button clicks from bubbling further up. */
preventEvents?: boolean;
}

const stopEvent = (event: React.SyntheticEvent) => {
event.stopPropagation()
}

/**
Expand All @@ -23,10 +30,22 @@ export const CardActions = ({
className = "",
inverseDirection = false,
noWrap = false,
preventEvents = false,
...otherProps
}: CardActionsProps) => {
let htmlElementProps: DOMAttributes<HTMLElement> = Object.create(null)
if (preventEvents) {
htmlElementProps = {
onPointerDown: stopEvent,
onMouseDown: stopEvent,
onPointerUp: stopEvent,
onMouseUp: stopEvent,
onClick: stopEvent
}
}
return (
<footer
{...htmlElementProps}
{...otherProps}
className={
`${eccgui}-card__actions` +
Expand Down
1 change: 1 addition & 0 deletions src/components/Dialog/SimpleDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export const SimpleDialog = ({
)}
{actions && (
<CardActions
preventEvents={true}
{...actionsProps}
inverseDirection
className={`${actionsProps?.className ?? ""} ${intentClassName}`}
Expand Down
Loading