Skip to content

Commit

Permalink
[NO JIRA][BpkPopover]: Check for onClick property in the target (#3523)
Browse files Browse the repository at this point in the history
  • Loading branch information
olliecurtis authored Jul 5, 2024
1 parent 474e064 commit ae72575
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions packages/bpk-component-popover/src/BpkPopover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,15 @@ const BpkPopover = ({
dismiss,
]);

const targetClick = target.props.onClick;
const referenceProps = getReferenceProps(
{
onClick: (event) => {
if (targetClick) {
event.stopPropagation();
targetClick(event);
}
},
const targetClick = target?.props?.onClick;
const referenceProps = targetClick ? getReferenceProps({
onClick: event => {
if (targetClick) {
event.stopPropagation();
targetClick(event);
}
}
)
}) : getReferenceProps();

const targetElement = isValidElement(target) ? (
cloneElement(target, {
Expand Down

0 comments on commit ae72575

Please sign in to comment.