Skip to content

fix: checkbox hover background center - #905

Open
elonehoo wants to merge 3 commits into
nuxt:mainfrom
elonehoo:fix/server-router-checkbox-hover-bg
Open

elonehoo wants to merge 3 commits into
nuxt:mainfrom
elonehoo:fix/server-router-checkbox-hover-bg

Conversation

@elonehoo

Copy link
Copy Markdown
Contributor

🔗 Linked issue

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

after

image

before

image

i don‘t know i write is success, but look in ok.

Comment thread packages/devtools-ui-kit/src/unocss.ts Outdated
'n-checkbox': 'inline-flex gap-1 items-center rounded',
'n-checkbox-hover': 'op100 n-bg-hover cursor-pointer',
'n-checkbox-box': 'border n-border-base w-1.1em h-1.1em mr-1 text-white flex flex-none items-center rounded-sm overflow-visible',
'n-checkbox-box': 'border n-border-base w-1.1em h-1.1em mr-1 ml-2 text-white flex flex-none items-center rounded-sm overflow-visible',

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.

Why it's 2? Maybe we should fix on the usage side?

@elonehoo elonehoo Oct 31, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

gap is 1 and margin-right is 1, so margin-left in 2

sorry, let i think of other idea

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

mabye i think this only idea

@antfu antfu added low hanging fruit Quick for a maintainer to finish p1-chore Changes no behavior (deps, docs, cleanup) DevTools v4 Reported against Nuxt DevTools v4 (main, default in Nuxt 5) labels Oct 23, 2026
@antfubot antfubot mentioned this pull request Nov 24, 2026
11 of 29 tasks

@antfubot antfubot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for this! I agree the hover background looks off-center. But this change can't go in as it is:

  • n-checkbox-box is the shared shortcut for every NCheckbox, about 20 places in the client: settings, timeline, components graph, module install list, analyze build, and more. Adding ml-2 there moves every checkbox 0.5rem to the right, so they stop lining up with the content around them. This is what @antfu pointed out above.
  • The checkbox on the server routes page has no label. So the left edge of the hover background is the box itself, and the only space is the box's mr-1 on the right.

Please fix this at the usage site instead, in packages/devtools/client/components/ServerRouteInputs.vue. For example, give the label-less NCheckbox symmetric padding (pl-1, which matches the existing mr-1, or px-1). Or, if you'd like a fix in the component itself, give n-checkbox symmetric horizontal padding and check that the labelled checkboxes still line up. Before/after screenshots of the server routes page and one labelled checkbox (for example on Settings) would be great.

Also, CI hasn't run on this branch. Please rebase on main.

🤖 Automated by an agent.

@antfubot

antfubot commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Thanks for spotting this, @elonehoo! I updated the branch with main (merge commit, no force-push) and reworked the fix.

What changed:

  • I removed the ml-2 from the shared n-checkbox-box shortcut, so labelled checkboxes stay where they were.
  • The real cause: a checkbox with no label still rendered an empty label <span>. With mr-1 on the box plus the gap-1, that gave the hover background 0.5rem of space on the right and none on the left.
  • NCheckbox now renders the label <span> only when there is slot content. When there is no label, the root gets -ml-2 pl-2 pr-1. With the box's mr-1, that is 0.5rem on each side. The negative margin cancels the left padding, and the total width stays the same as before. So the hover background is centered, and nothing around it moves.

How I checked: I put the server routes row layout and a labelled checkbox on a page in the ui-kit playground, then measured them in the browser before and after. The box and its neighbours sit at exactly the same pixel positions. The hover area padding went from 0px left / 8px right to 8px / 8px. Labelled checkboxes are unchanged. pnpm lint passes.

🤖 Automated by an agent.

@coderabbitai

coderabbitai Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The checkbox label gains spacing classes when no default slot exists. The slot span renders only when a default slot exists. Its checked-dependent opacity behaviour is unchanged.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Merge Risk: Minimal · up to d27d9

This is a small visual fix for the hover background of label-less checkboxes. No functional risk was found, and it is safe to merge after a quick visual check.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix: checkbox hover background center" matches the changeset. The raw summary describes the NCheckbox.vue label change that adds padding and negative margin when no default slot is provided…
Description check Passed The description relates to the changeset. It includes before and after screenshots of the checkbox hover area in the query editor, and it names the change type as chore. It is brief and partly unclear…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix: checkbox hover background center" matches the changeset. The raw summary describes the NCheckbox.vue label change that adds padding and negative margin when no default slot is provided, and the objectives say the PR centres the hover background for a label-less checkbox. The title is specific and follows the conventional commit prefix, so it passes.

Full details: Description check

Explanation

The description relates to the changeset. It includes before and after screenshots of the checkbox hover area in the query editor, and it names the change type as chore. It is brief and partly unclear ("i don't know i write is success"), but it still describes the visual change, so the check passes under the lenient criteria. The linked issue and detailed rationale are missing.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ce600142-0992-4caf-8604-98e27fb721d8
Commits

Reviewing files that changed from the base of the PR and between 8b02499 and d27d96d.

Files selected for processing: 1

  • packages/devtools-ui-kit/src/components/NCheckbox.vue

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@antfu
antfu enabled auto-merge (squash) December 2, 2026 01:47

This branch has not been deployed

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

Labels

DevTools v4 Reported against Nuxt DevTools v4 (main, default in Nuxt 5) low hanging fruit Quick for a maintainer to finish p1-chore Changes no behavior (deps, docs, cleanup)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants