Skip to content

feat: Add KBD component to labs#4001

Merged
alanbsmith merged 12 commits into
Workday:prerelease/majorfrom
RayRedGoose:issue3990-kbd-component
Jun 26, 2026
Merged

feat: Add KBD component to labs#4001
alanbsmith merged 12 commits into
Workday:prerelease/majorfrom
RayRedGoose:issue3990-kbd-component

Conversation

@RayRedGoose

@RayRedGoose RayRedGoose commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes: #3990

Adds a new KBD component to the Canvas Labs package for rendering keyboard shortcuts.

Release Category

Components

Release Note

A new KBD component has been added to the Canvas Labs (@workday/canvas-kit-labs-react) package for rendering keyboard shortcuts.

BREAKING CHANGES

A new KBD component has been added to the Canvas Labs (@workday/canvas-kit-labs-react) package for rendering keyboard shortcuts.


Checklist

For the Reviewer

  • PR title is short and descriptive
  • PR summary describes the change (Fixes/Resolves linked correctly)
  • PR Release Notes describes additional information useful to call out in a release message or removed if not applicable
  • Breaking Changes provides useful information to upgrade to this code or removed if not applicable

Where Should the Reviewer Start?

Areas for Feedback? (optional)

  • Code
  • Documentation
  • Testing
  • Codemods

Testing Manually

Screenshots or GIFs (if applicable)

Thank You Gif (optional)

Summary by CodeRabbit

  • New Features
    • Added the Canvas Kit KBD compound component with KBD.Item, including size (small/medium/large), variant (default/plain), RTL, and support for nested/dynamic items
    • Exposed the package kbd entry point, including the useKBDModel hook for advanced usage
    • Added Storybook examples and visual testing coverage for common KBD states
  • Documentation
    • Added KBD README and MDX docs, including Accessibility guidance; updated the v16 upgrade guide
  • Tests
    • Added an SSR test to confirm KBD rendering doesn’t throw

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a new KBD compound component under modules/labs-react/kbd, with shared model state, item rendering, package exports, Storybook docs/examples, SSR coverage, and upgrade-guide documentation.

Changes

KBD Compound Component

Layer / File(s) Summary
Props, stencils, and model
modules/labs-react/kbd/lib/KBD.tsx, modules/labs-react/kbd/lib/KBDItem.tsx, modules/labs-react/kbd/lib/useKBDModel.tsx
KBDProps, KBDItemProps, kbdStencil, kbdItemStencil, and useKBDModel define the shared KBD contract and styling state.
KBD and KBDItem implementation
modules/labs-react/kbd/lib/KBD.tsx, modules/labs-react/kbd/lib/KBDItem.tsx
KBD and KBDItem render semantic <kbd> markup, share model state, and apply the stencil classes.
Entry points and module files
modules/labs-react/index.ts, modules/labs-react/kbd/index.ts, modules/labs-react/kbd/LICENSE, modules/labs-react/kbd/README.md
The new kbd exports are wired into labs-react and the module gains README and license files.
Storybook docs, examples, and visual states
modules/labs-react/kbd/stories/KBD.mdx, modules/labs-react/kbd/stories/KBD.stories.tsx, modules/labs-react/kbd/stories/examples/*, modules/labs-react/kbd/stories/visual-testing/testing.stories.tsx, modules/labs-react/kbd/stories/tsconfig.json, modules/labs-react/kbd/spec/tsconfig.json
Storybook docs, example stories, visual-state coverage, and TypeScript configs are added for KBD.
SSR smoke test
modules/labs-react/kbd/spec/SSR.spec.tsx
A Node-environment SSR spec renders KBD with KBD.Item children and checks that server rendering does not throw.
Upgrade guide entry
modules/docs/mdx/16.0-UPGRADE-GUIDE.mdx
The v16 upgrade guide adds a KBD TOC entry and a new-components section describing the component and its usage.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

review in progress

Poem

🐇 A little KBD hopped in today,
With keys that jingle in a row.
Plain or sized, it found its way,
Through stories, tests, and docs aglow.
Tap tap — the rabbit gives a cheer,
Shortcut keys have landed here!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main change: adding a new KBD component to labs.
Linked Issues check ✅ Passed The PR implements the standalone Kbd component, exports it, adds Storybook docs and visual tests, and uses semantic markup.
Out of Scope Changes check ✅ Passed All changes are tied to the new KBD component, its docs, examples, and tests; no unrelated scope is evident.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands.

@cypress

cypress Bot commented Jun 15, 2026

Copy link
Copy Markdown

Workday/canvas-kit    Run #11109

Run Properties:  status check passed Passed #11109  •  git commit cc9bf391c4 ℹ️: Merge d8beb81e17f000a00c3399035c73b1211e7b3f34 into d6ad8e074e3198ed8ea07558a667...
Project Workday/canvas-kit
Branch Review issue3990-kbd-component
Run status status check passed Passed #11109
Run duration 02m 28s
Commit git commit cc9bf391c4 ℹ️: Merge d8beb81e17f000a00c3399035c73b1211e7b3f34 into d6ad8e074e3198ed8ea07558a667...
Committer Raisa Primerova
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 17
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 809
View all changes introduced in this branch ↗︎
UI Coverage  19.69%
  Untested elements 1523  
  Tested elements 371  
Accessibility  99.41%
  Failed rules  5 critical   5 serious   0 moderate   2 minor
  Failed elements 68  

@RayRedGoose RayRedGoose marked this pull request as ready for review June 23, 2026 15:22
@RayRedGoose RayRedGoose requested a review from a team as a code owner June 23, 2026 15:22
Copilot AI review requested due to automatic review settings June 23, 2026 15:22
@RayRedGoose RayRedGoose added the ready for review Code is ready for review label Jun 23, 2026

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

Introduces a new Labs KBD compound component (@workday/canvas-kit-labs-react/kbd) for rendering keyboard shortcuts with Storybook documentation, visual testing coverage, and an SSR smoke test.

Changes:

  • Added KBD and KBD.Item implementation using createComponent + createStencil
  • Added Storybook stories/MDX docs and Chromatic visual-testing states
  • Added an SSR Jest spec and exported kbd from the Labs package entrypoint

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
modules/labs-react/kbd/stories/visual-testing/testing.stories.tsx Adds Chromatic visual regression coverage across variants/sizes
modules/labs-react/kbd/stories/tsconfig.json Storybook TS config for the new KBD stories folder
modules/labs-react/kbd/stories/KBD.stories.tsx Storybook entry wiring examples + MDX docs
modules/labs-react/kbd/stories/KBD.mdx MDX documentation for KBD usage and API
modules/labs-react/kbd/stories/examples/Variant.tsx Variant example for docs/stories
modules/labs-react/kbd/stories/examples/Size.tsx Size example for docs/stories
modules/labs-react/kbd/stories/examples/RTL.tsx RTL usage example for docs/stories
modules/labs-react/kbd/stories/examples/Basic.tsx Basic usage example for docs/stories
modules/labs-react/kbd/spec/tsconfig.json Jest/spec TS config for the new component
modules/labs-react/kbd/spec/SSR.spec.tsx SSR smoke test for the new component
modules/labs-react/kbd/README.md Component README for Labs package documentation
modules/labs-react/kbd/LICENSE License file for the new module directory
modules/labs-react/kbd/lib/KBDItem.tsx Implements KBD.Item subcomponent
modules/labs-react/kbd/lib/KBD.tsx Implements KBD container + stencil
modules/labs-react/kbd/index.ts Public exports for the new module
modules/labs-react/index.ts Re-exports kbd from the Labs package root

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

Comment thread modules/labs-react/kbd/lib/KBDItem.tsx Outdated
Comment thread modules/labs-react/kbd/lib/KBDItem.tsx Outdated
Comment thread modules/labs-react/kbd/stories/examples/Basic.tsx Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
modules/labs-react/kbd/README.md (1)

5-7: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Minor: Improve sentence flow and clarity.

Line 5 ends with "currently in prerelease." followed by line 7 "A compound component...". The flow is awkward. Consider combining the sentences:

  • Option 1: "...currently in prerelease. This is a compound component..."
  • Option 2: "...currently in prerelease: a compound component..."
  • Option 3: "...currently in prerelease, a compound component..."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@modules/labs-react/kbd/README.md` around lines 5 - 7, The README.md file has
awkward sentence flow between the prerelease status statement (ending with
"currently in prerelease.") and the component description (starting with "A
compound component..."). Combine these two sentences for better readability by
either adding a transitional word like "This is", using a colon, or using a
comma to connect the prerelease status with the compound component description
in a single coherent statement.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@modules/labs-react/kbd/README.md`:
- Around line 5-7: The README.md file has awkward sentence flow between the
prerelease status statement (ending with "currently in prerelease.") and the
component description (starting with "A compound component..."). Combine these
two sentences for better readability by either adding a transitional word like
"This is", using a colon, or using a comma to connect the prerelease status with
the compound component description in a single coherent statement.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2a22f1cf-ff8c-4067-ad99-bbaa388b4b1e

📥 Commits

Reviewing files that changed from the base of the PR and between b96217a and 350ec3e.

📒 Files selected for processing (16)
  • modules/labs-react/index.ts
  • modules/labs-react/kbd/LICENSE
  • modules/labs-react/kbd/README.md
  • modules/labs-react/kbd/index.ts
  • modules/labs-react/kbd/lib/KBD.tsx
  • modules/labs-react/kbd/lib/KBDItem.tsx
  • modules/labs-react/kbd/spec/SSR.spec.tsx
  • modules/labs-react/kbd/spec/tsconfig.json
  • modules/labs-react/kbd/stories/KBD.mdx
  • modules/labs-react/kbd/stories/KBD.stories.tsx
  • modules/labs-react/kbd/stories/examples/Basic.tsx
  • modules/labs-react/kbd/stories/examples/RTL.tsx
  • modules/labs-react/kbd/stories/examples/Size.tsx
  • modules/labs-react/kbd/stories/examples/Variant.tsx
  • modules/labs-react/kbd/stories/tsconfig.json
  • modules/labs-react/kbd/stories/visual-testing/testing.stories.tsx

@RayRedGoose

Copy link
Copy Markdown
Contributor Author

@Workday/canvas-engineering Do we want to support basic model with items? Now KBD component is a simple compound component and behave like that:

import {KBD} from '@workday/canvas-kit-labs-react';

<KBD>
  <KBD.Item></KBD.Item>
  <KBD.Item>C</KBD.Item>
</KBD>;

and if there is a complex shortcut it could look like:

import {KBD} from '@workday/canvas-kit-labs-react';

<KBD>
  {[...].map(item => <KBD.Item>{item}</KBD.Item>)}
</KBD>;

By adding model and items we can have a render function for multiple icons, it could have the next syntax:

import {KBD} from '@workday/canvas-kit-labs-react';

<KBD items={[...]}>
  {item => <KBD.Item>{item}</KBD.Item>}
</KBD>;

I don't see there is a big different between these approaches, so decided to keep it simple for now. So I would like to hear your opinions on that.

@RayRedGoose RayRedGoose self-assigned this Jun 23, 2026
Comment thread modules/labs-react/kbd/lib/KBD.tsx Outdated
Comment thread modules/labs-react/kbd/lib/KBDItem.tsx Outdated
Comment thread modules/labs-react/kbd/lib/KBD.tsx Outdated
Comment thread modules/labs-react/kbd/stories/visual-testing/testing.stories.tsx Outdated
Comment thread modules/labs-react/kbd/lib/KBD.tsx Outdated
Comment thread modules/docs/mdx/16.0-UPGRADE-GUIDE.mdx

@sheelah sheelah 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.

Looking good. Left a few minor comments inline.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
modules/labs-react/kbd/stories/KBD.mdx (1)

74-94: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Document KBD.Item in the API section.

The examples make KBD.Item the primary public surface, but the API section only documents KBD and useKBDModel. Adding the item here will make the compound API discoverable without relying on the examples.

♻️ Proposed change
 ## Component API
 
 <SymbolDoc name="KBD" hideDescription />
+<SymbolDoc name="KBD.Item" hideDescription />
 
 ## Model
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@modules/labs-react/kbd/stories/KBD.mdx` around lines 74 - 94, The API section
for KBD is missing the compound item component, so add documentation for
KBD.Item alongside KBD and useKBDModel in the KBD.mdx story. Update the
Component API section to include a SymbolDoc entry for KBD.Item so the public
compound surface is discoverable without relying on the usage example.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@modules/labs-react/kbd/lib/KBD.tsx`:
- Around line 81-101: The dynamic items path in KBD may break for plain-string
`items` because `useListRenderItems(model, children)` relies on the collection’s
default item identity, which can resolve to undefined for primitive strings.
Inspect `KBD` and `useKBDModel` together with the underlying
`useListModel`/collection `getId` behavior, and update the dynamic rendering
path so string items get stable unique keys/ids before render while leaving the
static `KBD.Item` children flow unchanged.

---

Nitpick comments:
In `@modules/labs-react/kbd/stories/KBD.mdx`:
- Around line 74-94: The API section for KBD is missing the compound item
component, so add documentation for KBD.Item alongside KBD and useKBDModel in
the KBD.mdx story. Update the Component API section to include a SymbolDoc entry
for KBD.Item so the public compound surface is discoverable without relying on
the usage example.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 0011f9f8-f852-47ca-92e1-be5844a8dd82

📥 Commits

Reviewing files that changed from the base of the PR and between 229b65b and cda70ad.

📒 Files selected for processing (10)
  • modules/labs-react/kbd/index.ts
  • modules/labs-react/kbd/lib/KBD.tsx
  • modules/labs-react/kbd/lib/KBDItem.tsx
  • modules/labs-react/kbd/lib/useKBDModel.tsx
  • modules/labs-react/kbd/stories/KBD.mdx
  • modules/labs-react/kbd/stories/KBD.stories.tsx
  • modules/labs-react/kbd/stories/examples/Basic.tsx
  • modules/labs-react/kbd/stories/examples/Items.tsx
  • modules/labs-react/kbd/stories/examples/RTL.tsx
  • modules/labs-react/kbd/stories/visual-testing/testing.stories.tsx
✅ Files skipped from review due to trivial changes (3)
  • modules/labs-react/kbd/stories/examples/Items.tsx
  • modules/labs-react/kbd/index.ts
  • modules/labs-react/kbd/stories/KBD.stories.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • modules/labs-react/kbd/stories/examples/RTL.tsx
  • modules/labs-react/kbd/stories/visual-testing/testing.stories.tsx

Comment thread modules/labs-react/kbd/lib/KBD.tsx
@RayRedGoose RayRedGoose added the needs-a11y Extra attention from accessibility is needed label Jun 24, 2026

@williamjstanton williamjstanton 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.

Looks good to me, and fairly straightforward. I think there's a couple things we can improve in the docs noted in comments above. Thanks!

Comment thread modules/labs-react/kbd/stories/examples/Basic.tsx Outdated
Comment thread modules/docs/mdx/16.0-UPGRADE-GUIDE.mdx
@RayRedGoose RayRedGoose removed the needs-a11y Extra attention from accessibility is needed label Jun 25, 2026
@RayRedGoose

Copy link
Copy Markdown
Contributor Author

@williamjstanton added accessibility section and examples 👍

@RayRedGoose RayRedGoose added approved Code has been reviewed and approved (ship it) and removed ready for review Code is ready for review labels Jun 26, 2026
@RayRedGoose RayRedGoose force-pushed the issue3990-kbd-component branch from bcee319 to 199f6fb Compare June 26, 2026 16:58
@RayRedGoose RayRedGoose added automerge and removed approved Code has been reviewed and approved (ship it) labels Jun 26, 2026
@alanbsmith alanbsmith enabled auto-merge (squash) June 26, 2026 17:20
@alanbsmith alanbsmith merged commit 8528d9a into Workday:prerelease/major Jun 26, 2026
22 of 26 checks passed
@RayRedGoose RayRedGoose deleted the issue3990-kbd-component branch June 26, 2026 17:29
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.

7 participants