Skip to content

Add tooltip to checkboxes#125

Open
P-Gill97 wants to merge 7 commits into
mainfrom
add-tooltip-to-checkboxes
Open

Add tooltip to checkboxes#125
P-Gill97 wants to merge 7 commits into
mainfrom
add-tooltip-to-checkboxes

Conversation

@P-Gill97

@P-Gill97 P-Gill97 commented Jul 9, 2026

Copy link
Copy Markdown

https://openstax.atlassian.net/browse/CORE-2444

Update checkboxes to have tooltip like the radio buttons do. I needed this for the unlimited assignment attempts settings page. The tooltips will be defined in assessments assessments/packages/lambda/src/functions/serviceApi/versions/v0/routes/integration.ts

@P-Gill97 P-Gill97 self-assigned this Jul 9, 2026

@jivey jivey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small issue, I'm seeing the tooltip read twice in a screenreader (maybe we have the same issue on the radio component?) I wonder if you need the aria-describedby to be on the input itself.

@P-Gill97

Copy link
Copy Markdown
Author

@jivey Ahh Ok I'll fix that. I'm curious, what does your screen reader setup look like? I would like to set one up as well.

@jivey

jivey commented Jul 13, 2026

Copy link
Copy Markdown
Member

@P-Gill97 I tested this particular thing on Windows 11 with NVDA inside of a Parallels container, but I want to start using VoiceOver, I heard it's much better these days and it's definitely faster than firing up a VM. I'm also trying to get used to the Accessibility tab in chrome, though in this case I may not have noticed contents + description being an issue:

image

Which is why I prefer checking with NVDA/VoiceOver so I don't have guess how it'll actually be read.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds tooltip support to checkbox inputs, aligning their behavior with the existing radio tooltip pattern by introducing shared tooltip-trigger logic in the components layer.

Changes:

  • Introduces a shared useLabelTooltip hook in Tooltip.tsx for label-wrapped inputs.
  • Updates Radio to use the shared tooltip hook instead of its bespoke tooltip state/trigger logic.
  • Updates Checkbox to support tooltipText and adds a Storybook example; updates related snapshots.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/components/Tree/snapshots/Tree.spec.tsx.snap Snapshot update due to styled-components class name changes.
src/components/Tooltip.tsx Adds shared useLabelTooltip hook; adjusts tooltip-related imports.
src/components/Radio.tsx Refactors radio tooltip behavior to use useLabelTooltip.
src/components/Checkbox/Checkbox.tsx Adds tooltipText support and tooltip rendering path for checkboxes.
src/components/Checkbox/Checkbox.stories.tsx Adds a WithTooltip Storybook example for checkboxes.
src/components/Checkbox/snapshots/Checkbox.spec.tsx.snap Snapshot update due to styled-components class name changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -1,8 +1,10 @@
import { useRef } from 'react';

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npx tsc --noEmit passes clean. False positive.

Comment on lines +124 to +135
const { triggerProps, tooltipProps } = useTooltipTrigger({ delay: 0 }, state, triggerRef);

const { 'aria-describedby': _unusedDescribedBy, ...labelTriggerProps } = triggerProps;

return {
triggerRef,
triggerProps: labelTriggerProps,
labelDescription: tooltipText ? <VisuallyHidden>{tooltipText}</VisuallyHidden> : null,
tooltip: tooltipText && state.isOpen
? <CustomTooltip state={state} {...tooltipProps} placement={placement} aria-hidden={true}>{tooltipText}</CustomTooltip>
: null,
};

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stripping aria-describedby does not prevent assistive tech from announcing the tooltip. Also a disabled input isn't focusable, and describedby only speaks on focus so disabled checkboxes and radio inputs tooltips aren't announced.

Comment thread src/components/Checkbox/Checkbox.tsx
Comment on lines +31 to +42
export const Checkbox = ({ children, disabled, variant = 'primary', bold = false, size = 1.6, labelProps, tooltipText, ...props }: CheckboxProps) => {
const { triggerRef, triggerProps, labelDescription, tooltip } = useLabelTooltip(tooltipText);

return tooltipText
? <LabelWithTooltipWrapper>
<StyledLabel ref={triggerRef} bold={bold} variant={variant} isDisabled={disabled} {...triggerProps} {...labelProps}>
<StyledInput {...props} type="checkbox" variant={variant} checkboxSize={size} isDisabled={disabled} disabled={disabled} />
{children}
{labelDescription}
</StyledLabel>
{tooltip}
</LabelWithTooltipWrapper>

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tooltip behavior has not changed. Visually inspected and used VoiceOver to check accessibility.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@P-Gill97

Copy link
Copy Markdown
Author

@jivey Requirements changed on the issue I was adding these tooltips to checkboxes for. I think I'm gonna hold off on working on this PR for a bit I got it most of the way there and fixed the double read issue also made the tooltips work correctly on disabled boxes. I will keep PR open because this is something we should add.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants