Skip to content

Commit e35774d

Browse files
Change label structure to avoid IconHelp on the right when label on 2 lines
1 parent 186bf23 commit e35774d

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

src/lib/components/form/Form.component.tsx

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -171,26 +171,30 @@ const FormGroup = ({
171171
flex: 'none',
172172
}}
173173
>
174-
<Stack>
175-
<label
176-
htmlFor={id}
177-
id={`${LABEL_PREFIX}${id}`}
178-
ref={labelRef}
179-
style={{ opacity: disabled ? 0.5 : 1 }}
180-
>
181-
<Text>
182-
{label}
183-
{requireMode !== 'all' && required && ' *'}
184-
{requireMode === 'all' && !required && ' (optional)'}
185-
</Text>
186-
</label>
174+
<label
175+
htmlFor={id}
176+
id={`${LABEL_PREFIX}${id}`}
177+
ref={labelRef}
178+
style={{ opacity: disabled ? 0.5 : 1 }}
179+
>
180+
<Text>
181+
{label}
182+
{requireMode !== 'all' && required && ' *'}
183+
{requireMode === 'all' && !required && ' (optional)'}
184+
</Text>
187185
{labelHelpTooltip && (
188-
<IconHelp
189-
tooltipMessage={labelHelpTooltip}
190-
overlayStyle={maxWidthTooltip}
191-
/>
186+
<Box
187+
display="inline-block"
188+
marginLeft={spacing.r8}
189+
style={{ whiteSpace: 'nowrap' }}
190+
>
191+
<IconHelp
192+
tooltipMessage={labelHelpTooltip}
193+
overlayStyle={maxWidthTooltip}
194+
/>
195+
</Box>
192196
)}
193-
</Stack>
197+
</label>
194198
</div>
195199
<Stack
196200
direction={helpErrorPosition === 'right' ? 'horizontal' : 'vertical'}

0 commit comments

Comments
 (0)