Repository navigation
fix(studio): equal padding in the dataset source segmented control - #7230
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the sliding-pill segmented control in the DatasetSection component to use Framer Motion for smooth layout transitions, including support for reduced motion. The review feedback suggests using React's useId hook to dynamically scope the Framer Motion layoutId prop, which prevents potential animation conflicts and layout collisions if multiple instances of the component are rendered simultaneously.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| } from "@hugeicons/core-free-icons"; | ||
| import { HugeiconsIcon } from "@hugeicons/react"; | ||
| import { useNavigate } from "@tanstack/react-router"; | ||
| import { motion, useReducedMotion } from "motion/react"; |
There was a problem hiding this comment.
To prevent potential layoutId collisions when multiple instances of this component are rendered (e.g., during route transitions or in tests), we should scope the layoutId using a unique ID. Let's import useId from React.
import { motion, useReducedMotion } from "motion/react";
import { useId } from "react";
There was a problem hiding this comment.
Good catch. Added useId in 3f2dedb, appended to the existing react import block instead of a separate import.
| export function DatasetSection() { | ||
| const t = useT(); | ||
| const navigate = useNavigate(); | ||
| const reducedMotion = useReducedMotion(); |
| {datasetSource === item.value && ( | ||
| <motion.span | ||
| aria-hidden="true" | ||
| layoutId="dataset-source-pill" |
There was a problem hiding this comment.
Use the unique layoutId generated via useId to prevent layout animation conflicts across multiple instances of the segmented control.
| {datasetSource === item.value && ( | |
| <motion.span | |
| aria-hidden="true" | |
| layoutId="dataset-source-pill" | |
| {datasetSource === item.value && ( | |
| <motion.span | |
| aria-hidden="true" | |
| layoutId={"dataset-source-pill-" + layoutId} |
There was a problem hiding this comment.
Done in 3f2dedb. Since useId is already unique per instance the pill uses it directly without a string prefix.
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…nslothai#7230) * fix(studio): equal padding in dataset source segmented control * fix(studio): scope dataset source pill layoutId per component instance
Problem
On the Studio train page, the Dataset section has a Hugging Face / Local / Amazon S3 segmented control. Each button was forced to exactly one third of the track width with
flex-1, and the sliding pill was hard coded to 33.3% width.Since the three labels have very different lengths, the whitespace came out uneven: "Hugging Face" almost filled its pill while "Local" sat in a large empty segment, and the gaps between neighboring labels differed as well.
Fix
flex-autoinstead offlex-1. Each button takes its label's natural width plus an equal share of the leftover track space, so the control still spans the full card width but the padding around every label and the spacing between buttons is now identical.motionlayoutIdpill rendered inside the active button. The pill always matches the active button's true bounds and still animates smoothly between tabs.This matches the pattern already used by
ThemeSegmentedin settings (same spring transition and reduced motion support), so the Studio control is now consistent with the rest of the app.Testing
npm run typecheckpassesnpm run buildsucceeds