Skip to content

fix: view-switcher > add docs + demos#6640

Merged
GZolla merged 6 commits intomainfrom
gzolla/view-switcher-docs
Mar 2, 2026
Merged

fix: view-switcher > add docs + demos#6640
GZolla merged 6 commits intomainfrom
gzolla/view-switcher-docs

Conversation

@GZolla
Copy link
Contributor

@GZolla GZolla commented Feb 28, 2026

GAUD-9538

Adding a README and improving the demos for d2l-view-switcher

@GZolla GZolla requested a review from a team as a code owner February 28, 2026 02:42
if (!items.find(i => i.selected)) items[0].selected = true;
const selectedItems = items.filter(i => i.selected);
if (selectedItems.length === 0) items[0].selected = true;
if (selectedItems.length > 1) { // unselect all but the first selected item
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was added so the d2l-view-switcher-button demo would work properly on the component page

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this an existing bug, or were consumers expected to listen to the event and update the selected values accordingly (and know no longer need to)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A bug I found while working on the demos, thankfully there are no consumers outside of core(search)

Copy link
Contributor

Choose a reason for hiding this comment

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

Gotcha. It looks like this is unselecting all but the first item, not all but the first unselected item? As in, if the second and third are both selected, it unselects both of those.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It unselects all but the first selected item, I added a test for the use case

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah you're right, missed the initial filtering! 🤦‍♀️

@github-actions
Copy link
Contributor

Thanks for the PR! 🎉

We've deployed an automatic preview for this PR - you can see your changes here:

URL https://live.d2l.dev/prs/BrightspaceUI/core/pr-6640/

Note

The build needs to finish before your changes are deployed.
Changes to the PR will automatically update the instance.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you want the README up a level, not in the demo folder?

import '../view-switcher-button.js';
import '../../list/list-item-content.js';
import '../../list/list-item.js';
import { css, html, LitElement } from 'lit';
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this doesn't work properly with our published static demo pages. Other demo pages that do this (like labelled-mixin) also aren't working, and I guess we didn't notice.

@GZolla GZolla merged commit 05ba760 into main Mar 2, 2026
7 checks passed
@GZolla GZolla deleted the gzolla/view-switcher-docs branch March 2, 2026 22:09
@d2l-github-release-tokens
Copy link

🎉 This PR is included in version 3.220.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants