twbs / twbs/bootstrap

Tabs not working with Shadow Root

Open
#38,806 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

js v5
Dominant language
MDX
Stars
175k
Forks
78.6k
Avg merge
7h 19m
Merged PRs (30d)
35

Description

Prerequisites
Describe the issue

Tabs do not work inside a shadow root. The cause of this is the following function in SelectorEngine:

getElementFromSelector(element) {
      const selector = getSelector(element);
      return selector ? SelectorEngine.findOne(selector) : null;
    },

instead of calling findOne like that, it should be called using SelectorEngine.findOne(selector, element.getRootNode()) which would solve the problem.

This solution assumes that the tabs and containers lie within the same DOM, but this is a fair assumption.

Reduced test cases

JSfiddle was simpler for me. I just put

https://jsfiddle.net/djae3guf/

What operating system(s) are you seeing the problem on?

Linux

What browser(s) are you seeing the problem on?

Firefox

What version of Bootstrap are you using?

5.3.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the SelectorEngine getElementFromSelector function described in the issue, then reproduce the problem with the linked JSFiddle using tabs inside a shadow root. Confirm that tabs and their containers are in the same DOM, and verify that the tabs work in the Firefox scenario described once the issue is addressed.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.