Skip to content

Commit 502e580

Browse files
authored
feat(analysis): introduce optional clear button DEV-1194 (#6445)
### 📣 Summary Modern implementations of radio components don't allow de-selection. After updating the select one question type in the qualitative analysis section to mantine, we lost this functionality. To ensure the ability to de-select select one questions, they will appear with a "clear" button next to the "delete" button ### Notes Prerequisite for DEV-1169 ### 👀 Preview steps 1. ℹ️ have an account and a project with NLP questions and submissions 2. go to qualitative analysis 3. add a select-one question type 4. 🔴 [on main] notice that there is no clear button 5. 🟢 [on PR] notice the clear button exists and works
1 parent 7f3a0c7 commit 502e580

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

jsapp/js/components/processing/analysis/responseForms/responseWrapper.component.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import type { AnalysisQuestionInternal } from '../constants'
2222

2323
interface ResponseWrapperProps {
2424
uuid: string
25+
/** Adds a clear button with the given logic */
26+
onClear?: () => unknown
2527
children?: React.ReactNode
2628
}
2729

@@ -136,7 +138,6 @@ export default function ResponseWrapper(props: ResponseWrapperProps) {
136138

137139
<ActionIcon
138140
variant='light'
139-
color=''
140141
size='sm'
141142
iconName='edit'
142143
onClick={openQuestionInEditor}
@@ -149,6 +150,8 @@ export default function ResponseWrapper(props: ResponseWrapperProps) {
149150
}
150151
/>
151152

153+
{props.onClear && <ActionIcon variant='light' size='sm' iconName='close' onClick={props.onClear} />}
154+
152155
<ActionIcon
153156
variant='danger-secondary'
154157
size='sm'

jsapp/js/components/processing/analysis/responseForms/selectOneResponseForm.component.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export default function SelectOneResponseForm(props: SelectOneResponseFormProps)
7171
}
7272

7373
return (
74-
<ResponseWrapper uuid={props.uuid}>
74+
<ResponseWrapper uuid={props.uuid} onClear={() => onRadioChange('')}>
7575
<Radio
7676
options={getOptions()}
7777
name={question.labels._default}

jsapp/js/theme/kobo/ActionIcon.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ export const ActionIconThemeKobo = ActionIcon.extend({
1818
'--ai-bg': theme.colors.blue[9],
1919
'--ai-hover': theme.colors.blue[8],
2020
}),
21+
...(props.variant === 'light-gray' && {
22+
'--ai-color': theme.colors.gray[2],
23+
'--ai-bg': theme.colors.gray[7],
24+
'--ai-hover': theme.colors.gray[6],
25+
}),
2126
...(props.variant === 'transparent' && {
2227
'--ai-color': theme.colors.blue[4],
2328
'--ai-hover-color': theme.colors.blue[5],

0 commit comments

Comments
 (0)