Skip to content

Commit

Permalink
fix(AdaptiveTabs): add ReactNode support for hint
Browse files Browse the repository at this point in the history
  • Loading branch information
Marginy605 committed Oct 27, 2024
1 parent 53aedcb commit 03dd7af
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/components/AdaptiveTabs/AdaptiveTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type OpenChangeProps = Parameters<NonNullable<SelectProps['onOpenChange']>>[0];
export interface TabProps {
id: string;
title?: string | React.ReactNode;
hint?: string;
hint?: string | React.ReactNode;
active?: boolean;
disabled?: boolean;
onClick?: (id: string, event: React.MouseEvent) => void;
Expand All @@ -71,7 +71,7 @@ class Tab extends React.Component<TabProps> {
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
<div
className={b('tab', {active, disabled})}
title={stringTitle}
title={typeof stringTitle === 'string' ? stringTitle : undefined}
onClick={disabled ? undefined : this.onClick}
>
{title}
Expand Down Expand Up @@ -769,14 +769,14 @@ export class AdaptiveTabs<T> extends React.Component<AdaptiveTabsProps<T>, Adapt
const {items} = this.props;
const activeTab = items.find((item) => item.id === this.activeTab);
const tab = activeTab ?? items[0];
const hint = tab.hint ?? ((typeof tab.title === 'string' && tab.title) || tab.id);
const hint = tab.hint ?? (tab.title || tab.id);

return this.renderSwitcher({...switcherProps, text: hint, active: Boolean(activeTab)});
};

renderSwitcher = (
switcherProps: RenderControlProps & {
text: string;
text: string | React.ReactNode;
active?: boolean;
},
) => {
Expand Down

0 comments on commit 03dd7af

Please sign in to comment.