From c0c089275e3d5210a478f77b0745ffc27ec1d993 Mon Sep 17 00:00:00 2001 From: RoB Murdock Date: Tue, 15 Oct 2024 10:55:39 -0400 Subject: [PATCH] tweaking pop up menu triggers --- .../ContributionOverviewContent.kt | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/client/components/src/jsMain/kotlin/com/zegreatrob/coupling/client/components/contribution/ContributionOverviewContent.kt b/client/components/src/jsMain/kotlin/com/zegreatrob/coupling/client/components/contribution/ContributionOverviewContent.kt index c445e5180..d94adebf9 100644 --- a/client/components/src/jsMain/kotlin/com/zegreatrob/coupling/client/components/contribution/ContributionOverviewContent.kt +++ b/client/components/src/jsMain/kotlin/com/zegreatrob/coupling/client/components/contribution/ContributionOverviewContent.kt @@ -48,16 +48,16 @@ val ContributionOverviewContent by nfc { (part } val popperRef = useRef() val arrowRef = useRef() - val (referenceElement, setReferenceElement) = useState?>(null) - val popperInstance = usePopper(referenceElement?.first, popperRef.current, popperOptions(arrowRef)) - if (referenceElement != null) { - CouplingPopUp( - hide = false, - popperRef = popperRef, - arrowRef = arrowRef, - popperInstance = popperInstance, - ) { - ContributorMenu(referenceElement.second, players, party.id) + val (menuTarget, setMenuTarget) = useState?>(null) + val popperInstance = usePopper(menuTarget?.first, popperRef.current, popperOptions(arrowRef)) + CouplingPopUp( + hide = menuTarget != null, + popperRef = popperRef, + arrowRef = arrowRef, + popperInstance = popperInstance, + ) { + if (menuTarget != null) { + ContributorMenu(menuTarget.second, players, party.id) } } contributions.forEach { contribution -> @@ -66,7 +66,7 @@ val ContributionOverviewContent by nfc { (part contributors = contributors, key = contribution.id, onPlayerClick = { player, element -> - setReferenceElement(ReferenceElement(element)!! to player) + setMenuTarget(ReferenceElement(element)!! to player) popperInstance.forceUpdate?.invoke() }, )