Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #5900: TabPanel add visible prop #5904

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading