Skip to content

Commit

Permalink
Fix #5900: TabPanel add visible prop (#5904)
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware authored Feb 5, 2024
1 parent 78c9f6a commit e5c2cfd
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 39 deletions.
2 changes: 1 addition & 1 deletion components/lib/tabview/TabView.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const TabView = React.forwardRef((inProps, ref) => {
const getTabProp = (tab, name) => TabPanelBase.getCProp(tab, name);

const shouldUseTab = (tab) => {
return tab && ObjectUtils.isValidChild(tab, 'TabPanel') && hiddenTabsState.every((_i) => _i !== tab.key);
return tab && getTabProp(tab, 'visible') && ObjectUtils.isValidChild(tab, 'TabPanel') && hiddenTabsState.every((_i) => _i !== tab.key);
};

const findVisibleActiveTab = (i) => {
Expand Down
9 changes: 5 additions & 4 deletions components/lib/tabview/TabViewBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,10 @@ export const TabViewBase = ComponentBase.extend({
export const TabPanelBase = ComponentBase.extend({
defaultProps: {
__TYPE: 'TabPanel',
children: undefined,
className: null,
closable: false,
closeIcon: null,
contentClassName: null,
contentStyle: null,
disabled: false,
Expand All @@ -150,12 +152,11 @@ export const TabPanelBase = ComponentBase.extend({
headerStyle: null,
headerTemplate: null,
leftIcon: null,
rightIcon: null,
prevButton: null,
nextButton: null,
closeIcon: null,
prevButton: null,
rightIcon: null,
style: null,
children: undefined
visible: true
},
getCProp: (tab, name) => ObjectUtils.getComponentProp(tab, name, TabPanelBase.defaultProps),
getCProps: (tab) => ObjectUtils.getComponentProps(tab, TabPanelBase.defaultProps),
Expand Down
73 changes: 39 additions & 34 deletions components/lib/tabview/tabview.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,28 @@ export interface TabPanelPassThroughOptions {
* @group Properties
*/
export interface TabPanelProps {
/**
* Used to get the child elements of the component.
* @readonly
*/
children?: React.ReactNode | undefined;
/**
* Defines if tab can be removed.
* @defaultValue false
*/
closable?: boolean | undefined;
/**
* Style class of the tab header and content.
*/
className?: string | undefined;
/**
* Inline style of the tab content.
*/
contentStyle?: React.CSSProperties | undefined;
/**
* Style class of the tab content.
*/
contentClassName?: string | undefined;
/**
* Orientation of tab headers.
*/
Expand All @@ -163,6 +185,14 @@ export interface TabPanelProps {
* Header template of the tab to customize more.
*/
headerTemplate?: React.ReactNode | ((options: TabPanelHeaderTemplateOptions) => React.ReactNode);
/**
* Inline style of the tab header.
*/
headerStyle?: React.CSSProperties | undefined;
/**
* Style class of the tab header.
*/
headerClassName?: string | undefined;
/**
* Icons can be placed at left of a header.
*/
Expand All @@ -188,40 +218,6 @@ export interface TabPanelProps {
* @defaultValue false
*/
disabled?: boolean | undefined;
/**
* Defines if tab can be removed.
* @defaultValue false
*/
closable?: boolean | undefined;
/**
* Inline style of the tab header and content.
*/
style?: React.CSSProperties | undefined;
/**
* Style class of the tab header and content.
*/
className?: string | undefined;
/**
* Inline style of the tab header.
*/
headerStyle?: React.CSSProperties | undefined;
/**
* Style class of the tab header.
*/
headerClassName?: string | undefined;
/**
* Inline style of the tab content.
*/
contentStyle?: React.CSSProperties | undefined;
/**
* Style class of the tab content.
*/
contentClassName?: string | undefined;
/**
* Used to get the child elements of the component.
* @readonly
*/
children?: React.ReactNode | undefined;
/**
* Uses to pass attributes to DOM elements inside the component.
* @type {TabPanelPassThroughOptions}
Expand All @@ -232,11 +228,20 @@ export interface TabPanelProps {
* @type {PassThroughOptions}
*/
ptOptions?: PassThroughOptions;
/**
* Inline style of the tab header and content.
*/
style?: React.CSSProperties | undefined;
/**
* When enabled, it removes component related styles in the core.
* @defaultValue false
*/
unstyled?: boolean;
/**
* When set as false, hides the tab panel.
* @defaultValue true
*/
visible?: boolean | undefined;
}

/**
Expand Down

0 comments on commit e5c2cfd

Please sign in to comment.