Skip to content

Commit 0a1fd65

Browse files
committed
Fix: New data-active-key not set upon initialization
#7
1 parent d7be001 commit 0a1fd65

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

packages/bootstrap/src/Nav.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ const Nav: BsPrefixRefForwardingComponent<"div", NavProps> = (p: NavProps) => {
8181
[`${bsPrefix}-justified`]: local.justify,
8282
})}
8383
{...props}
84-
data-active-key={activeKey()}
8584
>
8685
{props.children}
8786
</BaseNav>

packages/bootstrap/src/Tabs.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ const Tabs = (p: TabsProps) => {
109109
mountOnEnter={local.mountOnEnter}
110110
unmountOnExit={local.unmountOnExit}
111111
>
112-
<Nav {...props} role="tablist" as="ul" data-active-key={activeKey()}>
112+
<Nav {...props} role="tablist" as="ul">
113113
<For each={tabs()}>
114114
{(tabProps) => (
115115
<RenderTab {...tabProps}>{tabProps.children}</RenderTab>

packages/core/src/Nav.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ const Nav = (p: NavProps) => {
142142
}
143143
};
144144

145+
const activeKey = () => makeEventKey(tabContext?.activeKey ?? local.activeKey)
146+
145147
return (
146148
<SelectableContext.Provider value={handleSelect}>
147149
<NavContext.Provider
@@ -150,7 +152,7 @@ const Nav = (p: NavProps) => {
150152
return local.role || (tabContext ? "tablist" : undefined);
151153
}, // used by NavLink to determine it's role
152154
get activeKey() {
153-
return makeEventKey(tabContext?.activeKey ?? local.activeKey);
155+
return activeKey();
154156
},
155157
get getControlledId() {
156158
return tabContext?.getControlledId || noop;
@@ -162,10 +164,11 @@ const Nav = (p: NavProps) => {
162164
>
163165
<Dynamic
164166
component={local.as}
167+
data-active-key={activeKey()}
165168
{...props}
166169
onKeyDown={handleKeyDown}
167170
ref={mergedRef}
168-
>
171+
>
169172
{props.children}
170173
</Dynamic>
171174
</NavContext.Provider>

0 commit comments

Comments
 (0)