From 4d8a0c8519e056d18d6cd99c101c7077b93fe0d2 Mon Sep 17 00:00:00 2001 From: Corepex Date: Fri, 22 Nov 2024 13:03:10 +0100 Subject: [PATCH 01/15] fixed open issue when clicking dropdown option --- .../components/preview-card/preview-card.tsx | 29 ++++++---- .../tabs/preview/flex-container.tsx | 53 +++++++++---------- 2 files changed, 43 insertions(+), 39 deletions(-) diff --git a/assets/js/src/core/components/preview-card/preview-card.tsx b/assets/js/src/core/components/preview-card/preview-card.tsx index c69153acc..d0d33f1e0 100644 --- a/assets/js/src/core/components/preview-card/preview-card.tsx +++ b/assets/js/src/core/components/preview-card/preview-card.tsx @@ -11,8 +11,8 @@ * @license https://github.com/pimcore/studio-ui-bundle/blob/1.x/LICENSE.md POCL and PCL */ -import { Button, Card, Checkbox } from 'antd' -import React, { useState } from 'react' +import { Button, Card, Checkbox, type MenuRef } from 'antd' +import React, { useRef, useState } from 'react' import { useStyle } from './preview-card.styles' import Meta from 'antd/es/card/Meta' import { Icon } from '../icon/icon' @@ -32,12 +32,11 @@ interface PreviewCardProps { onClick?: (e) => void } -export const PreviewCard = ({ - name, dropdownItems, imgSrc, size = SizeTypes.SMALL, onClick -}: PreviewCardProps -): React.JSX.Element => { +export const PreviewCard = (props: PreviewCardProps): React.JSX.Element => { + const { size = SizeTypes.SMALL } = props const { styles } = useStyle() const [selected, setSelected] = useState(false) + const dropdownMenuRef = useRef(null) let classCard: string = '' let classImg: string = 'img' @@ -62,13 +61,20 @@ export const PreviewCard = ({ cover={
} - onClick={ onClick } + onClick={ (event) => { + if ( + dropdownMenuRef.current === null || + dropdownMenuRef.current.menu?.list.contains(event.target as Node) === false + ) { + props.onClick?.(event) + } + } } >