Skip to content

Commit

Permalink
Merge pull request #2345 from SpareBank1/develop_clickable-card-selec…
Browse files Browse the repository at this point in the history
…t-text

fix(ffe-cards-react): possible to copy text in card
  • Loading branch information
pethel authored Oct 7, 2024
2 parents 2cd5fad + 6d91000 commit 052ffb8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/ffe-cards-react/src/components/WithCardAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ function WithCardActionForwardRef<As extends ElementType>(
isUsingCardAction && `${baseClassName}--clickable`,
)}
onClick={(e: React.MouseEvent<HTMLElement>) => {
if (!cardActionInnerRef.current?.contains(e.target as Node)) {
const hasSelectedText = !!window.getSelection()?.toString()
.length;
if (
!hasSelectedText &&
!cardActionInnerRef.current?.contains(e.target as Node)
) {
cardActionInnerRef.current?.click();
}
onClick?.(e);
Expand Down

0 comments on commit 052ffb8

Please sign in to comment.