From 955e89c3d916546dd5a2479a875e170ffeff8c1c Mon Sep 17 00:00:00 2001 From: David Wallace Date: Fri, 11 Jul 2025 08:23:56 +0200 Subject: [PATCH 01/14] bump version to 2.3.3 Signed-off-by: David Wallace --- rdmo/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rdmo/__init__.py b/rdmo/__init__.py index ef6497d05..ed5cc1722 100644 --- a/rdmo/__init__.py +++ b/rdmo/__init__.py @@ -1 +1 @@ -__version__ = "2.3.2" +__version__ = "2.3.3" From 1dea78cf7c319d914b5d8c4fae20500d5054f975 Mon Sep 17 00:00:00 2001 From: Jochen Klar Date: Mon, 4 Aug 2025 14:14:17 +0200 Subject: [PATCH 02/14] Add adjust label hook for radio and checkbox (#1398) --- .../components/main/widget/CheckboxWidget.js | 11 ++++++++--- .../components/main/widget/RadioInput.js | 11 +++++++++-- .../assets/js/interview/hooks/useAdjustLabel.js | 17 +++++++++++++++++ 3 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 rdmo/projects/assets/js/interview/hooks/useAdjustLabel.js diff --git a/rdmo/projects/assets/js/interview/components/main/widget/CheckboxWidget.js b/rdmo/projects/assets/js/interview/components/main/widget/CheckboxWidget.js index 87e913a66..92950b1fb 100644 --- a/rdmo/projects/assets/js/interview/components/main/widget/CheckboxWidget.js +++ b/rdmo/projects/assets/js/interview/components/main/widget/CheckboxWidget.js @@ -1,10 +1,11 @@ -import React from 'react' +import React, { useRef } from 'react' import PropTypes from 'prop-types' - import { getQuestionTextId, getQuestionHelpId } from '../../../utils/question' import { gatherOptions } from '../../../utils/options' +import useAdjustLabel from '../../../hooks/useAdjustLabel' + import QuestionCopyValues from '../question/QuestionCopyValues' import QuestionEraseValues from '../question/QuestionEraseValues' import QuestionError from '../question/QuestionError' @@ -16,6 +17,10 @@ import CheckboxInput from './CheckboxInput' const CheckboxWidget = ({ page, question, sets, values, siblings, currentSet, disabled, createValue, updateValue, deleteValue, copyValue }) => { + const ref = useRef(null) + + useAdjustLabel(ref) + const handleCreateValue = (attrsList) => { attrsList.forEach(attrs => { createValue({ @@ -35,7 +40,7 @@ const CheckboxWidget = ({ page, question, sets, values, siblings, currentSet, di return (
-
+
{ + + const ref = useRef(null) + + useAdjustLabel(ref) + const handleChange = (option) => { if (option.has_provider) { updateValue(value, { @@ -46,7 +53,7 @@ const RadioInput = ({ question, value, options, disabled, updateValue, buttons } }) return ( -
+
{buttons}
{ + useEffect(() => { + if (ref.current) { + // find the .buttons node and get it's width + const buttons = ref.current.querySelector('.buttons') + const buttonsWidth = buttons.offsetWidth + + // find the first label for a radio or checkbox and adjust the right padding + const label = ref.current.querySelector('.radio:first-child label, .checkbox:first-child label') + label.style.paddingRight = `${label.style.paddingRight + buttonsWidth}px` + } + }, []) +} + +export default useAdjustLabel From 94e682006b918bfc4b8865f0a9a63284de2858a8 Mon Sep 17 00:00:00 2001 From: Jochen Klar Date: Thu, 7 Aug 2025 11:41:44 +0200 Subject: [PATCH 03/14] Fix adjust label hook --- .../components/main/widget/CheckboxInput.js | 10 ++++++++-- .../components/main/widget/CheckboxWidget.js | 10 ++-------- .../assets/js/interview/hooks/useAdjustLabel.js | 14 ++++++++++---- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/rdmo/projects/assets/js/interview/components/main/widget/CheckboxInput.js b/rdmo/projects/assets/js/interview/components/main/widget/CheckboxInput.js index 87e4438de..7f8b77f80 100644 --- a/rdmo/projects/assets/js/interview/components/main/widget/CheckboxInput.js +++ b/rdmo/projects/assets/js/interview/components/main/widget/CheckboxInput.js @@ -1,9 +1,11 @@ -import React from 'react' +import React, { useRef } from 'react' import PropTypes from 'prop-types' import classNames from 'classnames' import { useDebouncedCallback } from 'use-debounce' import { isEmpty, isNil } from 'lodash' +import useAdjustLabel from '../../../hooks/useAdjustLabel' + import AdditionalTextInput from './common/AdditionalTextInput' import AdditionalTextareaInput from './common/AdditionalTextareaInput' import OptionHelp from './common/OptionHelp' @@ -11,6 +13,10 @@ import OptionText from './common/OptionText' const CheckboxInput = ({ question, value, option, optionIndex, disabled, onCreate, onUpdate, onDelete }) => { + const ref = useRef(null) + + useAdjustLabel(ref) + const checked = !isNil(value) const classnames = classNames('checkbox', { @@ -64,7 +70,7 @@ const CheckboxInput = ({ question, value, option, optionIndex, disabled, onCreat }, 500) return ( -
+