Skip to content

Commit 6adf530

Browse files
authored
fix(tabs): prevent error when using with react (#2492)
Closes #2491
1 parent d5c6c19 commit 6adf530

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

.changeset/pf-tabs-id-cc.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
"@patternfly/elements": "patch"
3+
---
4+
`<pf-tabs>`: prevent error when using in certain javascript frameworks

elements/pf-tabs/BaseTabs.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ export abstract class BaseTabs extends LitElement {
7373

7474
#activeIndex = 0;
7575

76-
id: string = this.id || getRandomId(this.localName);
77-
7876
/**
7977
* Tab activation
8078
* Tabs can be either [automatic](https://w3c.github.io/aria-practices/examples/tabs/tabs-automatic.html) activated
@@ -139,6 +137,7 @@ export abstract class BaseTabs extends LitElement {
139137

140138
override connectedCallback() {
141139
super.connectedCallback();
140+
this.id ||= getRandomId(this.localName);
142141
this.addEventListener('expand', this.#onTabExpand);
143142
BaseTabs.#instances.add(this);
144143
}

0 commit comments

Comments
 (0)