Skip to content

docs: add proper example for code snippet multi-dropdown#5762

Merged
Ninfa-Jeon merged 2 commits intocanonical:mainfrom
Ninfa-Jeon:code-snippet-example
Feb 27, 2026
Merged

docs: add proper example for code snippet multi-dropdown#5762
Ninfa-Jeon merged 2 commits intocanonical:mainfrom
Ninfa-Jeon:code-snippet-example

Conversation

@Ninfa-Jeon
Copy link
Contributor

@Ninfa-Jeon Ninfa-Jeon commented Feb 26, 2026

Done

  • Added a working example for multi-dropdown code snippet

Fixes #5761

QA

  • Open demo
  • Review updated documentation:
    • Verify that the examples for code snippet with multiple dropdowns work.

Check if PR is ready for release

If this PR contains Vanilla SCSS or macro code changes, it should contain the following changes to make sure it's ready for the release:

  • PR should have one of the following labels to automatically categorise it in release notes:
    • Feature 🎁, Breaking Change 💣, Bug 🐛, Documentation 📝, Maintenance 🔨.
  • Vanilla version in package.json should be updated relative to the most recent release, following semver convention
    • if existing APIs (CSS classes & macro APIs) are not changed it can be a bugfix release (x.x.X)
    • if existing APIs (CSS classes & macro APIs) are changed/added/removed it should be a minor version (x.X.0)
    • see the wiki for more details
  • Any changes to component class names (new patterns, variants, removed or added features) or macros should be listed on the what's new page.

Screenshots

Screenshot 2026-02-26 at 11 16 15 PM

@webteam-app
Copy link

Copy link
Contributor

Copilot AI left a comment

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 fixes a bug in the code snippet component where the architecture dropdown (amd64/i386) in the multi-dropdown example wasn't functioning. Previously, only the channel dropdown (stable/beta/edge) worked because the architecture dropdown options had empty values. The fix implements a cascading dropdown pattern where selecting an architecture shows the appropriate channel dropdown, which then displays the corresponding code panel.

Changes:

  • Updated JavaScript to handle cascading dropdowns where dropdown options can point to other dropdowns instead of just code panels
  • Refactored HTML examples to use unique, properly-referenced IDs that enable the cascading dropdown functionality
  • Added null safety checks when accessing DOM elements

Reviewed changes

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

File Description
templates/docs/examples/patterns/code-snippet/_script.js Added logic to detect and handle cascading dropdowns (when a dropdown option points to another dropdown instead of a code panel), including proper panel hiding/showing and null safety checks
templates/docs/examples/patterns/code-snippet/_dropdown-multiple.html Updated all three code snippet examples with unique IDs and proper option values to implement the cascading dropdown pattern (architecture → channel → code panel)

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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


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

Copy link
Member

@bartaz bartaz left a comment

Choose a reason for hiding this comment

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

LGTM. The accessibility improvement would be a nice touch.

@Ninfa-Jeon Ninfa-Jeon merged commit a7d0939 into canonical:main Feb 27, 2026
7 checks passed
@Ninfa-Jeon Ninfa-Jeon deleted the code-snippet-example branch February 27, 2026 10:54
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.

[Bug]: Code snippet dropdowns example is not fully working

4 participants