From a27f9cf25dfb1b3c059273d862b03d788379cf28 Mon Sep 17 00:00:00 2001 From: Pascal Precht Date: Fri, 19 Mar 2021 11:21:02 +0100 Subject: [PATCH] fix(StatusRadioButtonRow): ensure checked state is propagated properly There were cases in which this component was used and its `checked` state wasn't properly emitted to the underlying component. This commit fixes that by ensuring the `MouseArea` only alters the radio button's `checked` state and let the radio button handle the event propagation. --- ui/shared/status/StatusRadioButtonRow.qml | 30 ++++++++++++++--------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/ui/shared/status/StatusRadioButtonRow.qml b/ui/shared/status/StatusRadioButtonRow.qml index 0507f6ef17..1556bc2302 100644 --- a/ui/shared/status/StatusRadioButtonRow.qml +++ b/ui/shared/status/StatusRadioButtonRow.qml @@ -31,6 +31,17 @@ Rectangle { anchors.leftMargin: Style.current.padding } + MouseArea { + cursorShape: Qt.PointingHandCursor + anchors.fill: parent + hoverEnabled: true + onEntered: root.isHovered = true + onExited: root.isHovered = false + onClicked: { + radioButton.checked = true + } + } + StatusRadioButton { id: radioButton anchors.verticalCenter: parent.verticalCenter @@ -40,18 +51,13 @@ Rectangle { rightPadding: 0 checked: root.checked onCheckedChanged: root.radioCheckedChanged(checked) - } - - MouseArea { - cursorShape: Qt.PointingHandCursor - anchors.fill: parent - hoverEnabled: true - onEntered: root.isHovered = true - onExited: root.isHovered = false - onClicked: { - if (!radioButton.checked) { - root.radioCheckedChanged(true) - } + MouseArea { + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + anchors.fill: parent + onPressed: mouse.accepted = false + onEntered: root.isHovered = true } } + }