Skip to content

Route-derived class names on the demo pane can collide with add-on CSS #164

Description

@paodb

What happens

TabbedDemo.showRouterLayoutContent names the demo pane after the segments of the demo's @Route, with no prefix. For @Route("splide/image") the pane becomes:

<div id="content" class="splide splide-image demos-v25">

Since the first segment is added on its own, the pane gets a bare, un-namespaced class name that is entirely up to the add-on's base path. If the add-on's own stylesheet uses that same name as a global selector, it now also applies to the demo pane.

Concrete case

The Splide add-on globally imports the Splide library stylesheet, which contains:

.splide { visibility: hidden }
.splide.is-initialized, .splide.is-rendered { visibility: visible }

The library hides .splide until its JS mounts. The demo pane matches that rule but never gets is-initialized — only the real slider roots inside it do. Result: anything placed in the pane other than the slider itself (a description paragraph, a caption, a button) is laid out but never painted. It is in the DOM with real dimensions, just invisible, which makes it look like the component was never added.

Suggested fix

Prefix the generated class names, e.g. demo-splide / demo-splide-image instead of splide / splide-image. That removes the whole class of collision for every add-on, instead of one add-on at a time.

Note this is breaking for any stylesheet that already targets the current names.

Workaround

Re-show the pane from the application's own stylesheet:

.splide[class*="demos-v"] { visibility: visible; }

Version

commons-demo 5.4.0

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

Status
In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions