Skip to content

fix(grid): use classNames for GridColumn instead of a template literal - #3239

Merged
interactivellama merged 2 commits into
salesforce:masterfrom
zigzagdev:fix/grid-column-classname
Oct 19, 2026
Merged

interactivellama merged 2 commits into
salesforce:masterfrom
zigzagdev:fix/grid-column-classname

Conversation

@zigzagdev

@zigzagdev zigzagdev commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #

Additional description

Motivation

Grid.Column built its class name with a plain template literal instead of the classNames utility.
Since className is an optional prop, rendering Grid.Column without one produced the literal string "undefined slds-col" as the class attribute on the DOM node.

What I have done

I changed GridColumn.getClassName() in components/grid/index.tsx to use classNames(this.props.className, 'slds-col'), matching the pattern already used by the sibling Grid class in the same file.

Test Plans

  • grid had no test file at all before this change, so I added components/grid/__tests__/grid.test.jsx.
    The new file covers three cases. Grid still applies its flavor modifier class. Grid.Column renders slds-col and never contains the word undefined in its class attribute when no className prop is passed. Grid.Column merges a provided className with slds-col, also without ever containing undefined.

CONTRIBUTOR checklist (do not remove)

Please complete for every pull request.

Green gate — all of these must pass locally (CI runs the same):

  • npm run lint passes with 0 errors (npm run lint:fix to auto-fix). Warnings are the tracked gradual-migration backlog; do not add new errors.
  • npm run typecheck is clean (tsc --noEmit).
  • npm test -- --run passes — this runs both Vitest projects (jsdom unit + real-browser browser) and the story HTML snapshots. If you changed rendered markup on purpose, update snapshots with npm test -- --run -u and review the diff.
  • npm run build succeeds (type-check + Vite library build + .d.ts + entry shims).

Behavior & docs:

  • First-time contributors: sign the CLA (a bot will comment with instructions).
  • Added/updated Vitest + React Testing Library tests for the change (template: components/button/__tests__). New props and bug fixes should get a regression test. Tests that genuinely need a real browser (focus traversal, layout/measurement, canvas) go in a *.browser.test.jsx file (the browser project); everything else is jsdom.
  • Reviewed the component's Storybook stories: npm run storybook → http://localhost:6007/. Confirm the story actually renders and behaves (deprecated Storyshots/Karma are gone; there is no separate browser-tests server).
  • Story/example code uses the component's real prop API (e.g. render-props like onRenderContent / onRenderVisualPicker, icon props, events), not assumptions — a common source of "component looks broken" reports has been stories authored against the wrong API. Cross-check against components/<name>/__examples__.
  • Storybook Accessibility (a11y) panel shows no new violations for the affected stories.
  • If you added or changed a type, remember runtime PropTypes were removed in the TS migration — types are the contract. Ship accurate .d.ts (they're generated by the build); JS consumers rely on them via editor type-acquisition.

REVIEWER checklist (do not remove)

  • CI is green (GitHub Actions CI workflow: lint, typecheck, test, build). Chromatic visual review, if configured, has been checked.
  • Change has adequate test coverage; bug fixes include a regression test.
  • Reviewed the affected Storybook stories and their a11y panels.
  • Rendered markup still conforms to SLDS — check the story HTML snapshot diff (components/__tests__/__snapshots__/story-snapshots.test.jsx.snap).
  • Public API / package surface: if exports changed, the deep-import contract still holds (@salesforce/design-system-react/components/<name> and nested paths resolve for ESM, CJS, and types). Removing/renaming a public component or export is a breaking change → feat!:/BREAKING CHANGE: and a major version bump.

GridColumn built its className with a plain template literal,
`${this.props.className} slds-col`, instead of the classNames utility
that the sibling Grid class already uses. Since className is
optional, rendering a Grid.Column without one produced the literal
string "undefined slds-col" as the class attribute.

Not a rewrite regression, the pre-rewrite class component had the
same template literal.
Verifies Grid.Column never renders the literal string "undefined" in
its class attribute, with and without a className prop.
@interactivellama
interactivellama merged commit 109d67c into salesforce:master Oct 19, 2026
7 checks passed
@welcome

welcome Bot commented Oct 19, 2026

Copy link
Copy Markdown

Congrats on merging your first pull request to Design System React! 🎉
If you have a moment, please fill out this five question survey, we would appreciate it.
On behalf of Salesforce's customers, partners, product specialists and employees, we would like offer sincere thanks and appreciation for helping make our user experience better. We look forward to working with you more in the future.
This definitely calls for a high five! Alt High Five

@zigzagdev
zigzagdev deleted the fix/grid-column-classname branch October 19, 2026 03:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants