Skip to content
Open
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
1 change: 1 addition & 0 deletions packages/web/src/components/list/MultiDropdownList.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export interface MultiDropdownList extends CommonProps {
preferencesPath?: string;
showClear?: boolean;
endpoint?: types.endpointConfig;
showOnlyOneOption?: boolean;
}

declare const MultiDropdownList: React.ComponentClass<MultiDropdownList>;
Expand Down
6 changes: 6 additions & 0 deletions packages/web/src/components/list/MultiDropdownList.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,10 @@ class MultiDropdownList extends Component {
return isFunction(renderError) ? renderError(error) : renderError;
}

if (this.state.options && this.state.options.length <= 1 && !this.props.showOnlyOneOption) {
return null;
}

if (!this.hasCustomRenderer && this.state.options.length === 0) {
if (this.props.renderNoResults && !this.props.isLoading) {
return this.props.renderNoResults();
Expand Down Expand Up @@ -494,6 +498,7 @@ MultiDropdownList.propTypes = {
showClear: types.bool,
isOpen: types.bool,
endpoint: types.endpoint,
showOnlyOneOption: types.bool,
};

MultiDropdownList.defaultProps = {
Expand All @@ -513,6 +518,7 @@ MultiDropdownList.defaultProps = {
showLoadMore: false,
loadMoreLabel: 'Load More',
isOpen: false,
showOnlyOneOption: true,
};

// Add componentType for SSR
Expand Down
1 change: 1 addition & 0 deletions packages/web/src/components/list/MultiList.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export interface MultiList extends CommonProps {
index?: string;
preferencesPath?: string;
endpoint?: types.endpointConfig;
showOnlyOneOption?: boolean;
}

declare const MultiList: React.ComponentClass<MultiList>;
Expand Down
6 changes: 6 additions & 0 deletions packages/web/src/components/list/MultiList.js
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,10 @@ class MultiList extends Component {
return isFunction(renderError) ? renderError(error) : renderError;
}

if (this.state.options && this.state.options.length <= 1 && !this.props.showOnlyOneOption) {
return null;
}

if (!this.hasCustomRenderer && this.state.options && this.state.options.length === 0) {
return this.props.renderNoResults ? this.props.renderNoResults() : null;
}
Expand Down Expand Up @@ -661,6 +665,7 @@ MultiList.propTypes = {
loadMoreLabel: types.title,
index: types.string,
endpoint: types.endpoint,
showOnlyOneOption: types.bool,
};

MultiList.defaultProps = {
Expand All @@ -678,6 +683,7 @@ MultiList.defaultProps = {
missingLabel: 'N/A',
showLoadMore: false,
loadMoreLabel: 'Load More',
showOnlyOneOption: true,
};

// Add componentType for SSR
Expand Down
1 change: 1 addition & 0 deletions packages/web/src/components/list/SingleDropdownList.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export interface SingleDropdownList extends CommonProps {
preferencesPath?: string;
showClear?: boolean;
endpoint?: types.endpointConfig;
showOnlyOneOption?: boolean;
}

declare const SingleDropdownList: React.ComponentClass<SingleDropdownList>;
Expand Down
6 changes: 6 additions & 0 deletions packages/web/src/components/list/SingleDropdownList.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,10 @@ class SingleDropdownList extends Component {
return isFunction(renderError) ? renderError(error) : renderError;
}

if (this.state.options && this.state.options.length <= 1 && !this.props.showOnlyOneOption) {
return null;
}

if (!this.hasCustomRenderer && this.state.options.length === 0) {
if (this.props.renderNoResults && !this.props.isLoading) {
return this.props.renderNoResults();
Expand Down Expand Up @@ -402,6 +406,7 @@ SingleDropdownList.propTypes = {
showClear: types.bool,
isOpen: types.bool,
endpoint: types.endpoint,
showOnlyOneOption: types.bool,
};

SingleDropdownList.defaultProps = {
Expand All @@ -420,6 +425,7 @@ SingleDropdownList.defaultProps = {
showLoadMore: false,
loadMoreLabel: 'Load More',
isOpen: false,
showOnlyOneOption: true,
};

// Add componentType for SSR
Expand Down
1 change: 1 addition & 0 deletions packages/web/src/components/list/SingleList.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export interface SingleList extends CommonProps {
preferencesPath?: string;
enableStrictSelection?: boolean;
endpoint?: types.endpointConfig;
showOnlyOneOption?: boolean;
}

declare const SingleList: React.ComponentClass<SingleList>;
Expand Down
6 changes: 6 additions & 0 deletions packages/web/src/components/list/SingleList.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,10 @@ class SingleList extends Component {
return isFunction(renderError) ? renderError(error) : renderError;
}

if (this.state.options && this.state.options.length <= 1 && !this.props.showOnlyOneOption) {
return null;
}

if (!this.hasCustomRenderer && this.state.options.length === 0) {
if (this.props.renderNoResults && !this.props.isLoading) {
return this.props.renderNoResults();
Expand Down Expand Up @@ -552,6 +556,7 @@ SingleList.propTypes = {
index: types.string,
enableStrictSelection: types.bool,
endpoint: types.endpoint,
showOnlyOneOption: types.bool,
};

SingleList.defaultProps = {
Expand All @@ -570,6 +575,7 @@ SingleList.defaultProps = {
showLoadMore: false,
loadMoreLabel: 'Load More',
enableStrictSelection: false,
showOnlyOneOption: true,
};

// Add componentType for SSR
Expand Down