fix: Check correct prop for section visibility
Root cause: Wrong prop check - Was checking: child.props['data-section-id'] - Should check: child.props.id Why this matters: - FormSection receives 'id' as a React prop - 'data-section-id' is only a DOM attribute - React.Children.map sees React props, not DOM attributes - So child.props['data-section-id'] was always undefined - Condition never matched, no hidden class applied - All sections stayed visible Fix: - Check child.props.id instead - Cast to string for type safety - Now condition matches correctly - Hidden class applied to inactive sections Result: ✅ Only active section visible ✅ Works on desktop and mobile ✅ Simple one-line fix per location
This commit is contained in:
@@ -119,8 +119,8 @@ export function VerticalTabForm({ tabs, children, className }: VerticalTabFormPr
|
|||||||
className="flex-1 overflow-y-auto pr-2"
|
className="flex-1 overflow-y-auto pr-2"
|
||||||
>
|
>
|
||||||
{React.Children.map(children, (child) => {
|
{React.Children.map(children, (child) => {
|
||||||
if (React.isValidElement(child) && child.props['data-section-id']) {
|
if (React.isValidElement(child) && child.props.id) {
|
||||||
const sectionId = child.props['data-section-id'];
|
const sectionId = child.props.id as string;
|
||||||
const isActive = sectionId === activeTab;
|
const isActive = sectionId === activeTab;
|
||||||
const originalClassName = child.props.className || '';
|
const originalClassName = child.props.className || '';
|
||||||
return React.cloneElement(child as React.ReactElement<any>, {
|
return React.cloneElement(child as React.ReactElement<any>, {
|
||||||
@@ -136,8 +136,8 @@ export function VerticalTabForm({ tabs, children, className }: VerticalTabFormPr
|
|||||||
{/* Mobile: Content Area */}
|
{/* Mobile: Content Area */}
|
||||||
<div className="lg:hidden">
|
<div className="lg:hidden">
|
||||||
{React.Children.map(children, (child) => {
|
{React.Children.map(children, (child) => {
|
||||||
if (React.isValidElement(child) && child.props['data-section-id']) {
|
if (React.isValidElement(child) && child.props.id) {
|
||||||
const sectionId = child.props['data-section-id'];
|
const sectionId = child.props.id as string;
|
||||||
const isActive = sectionId === activeTab;
|
const isActive = sectionId === activeTab;
|
||||||
const originalClassName = child.props.className || '';
|
const originalClassName = child.props.className || '';
|
||||||
return React.cloneElement(child as React.ReactElement<any>, {
|
return React.cloneElement(child as React.ReactElement<any>, {
|
||||||
|
|||||||
Reference in New Issue
Block a user