Skip to content

Commit

Permalink
fix: enforce logic for displaying clear button for singleselect when …
Browse files Browse the repository at this point in the history
…its disabled
  • Loading branch information
harshpatel-crest committed Jun 17, 2021
1 parent 61011a3 commit d430c85
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ui/src/main/webapp/components/BaseFormView.jsx
Expand Up @@ -169,7 +169,7 @@ class BaseFormView extends PureComponent {
oauth: 'OAuth 2.0 Authentication',
};
entity.options = {};
entity.options.isClearable = true;
entity.options.hideClearBtn = true;
entity.options.autoCompleteFields = authType.map((type) => {
return { label: content[type], value: type };
});
Expand Down
8 changes: 5 additions & 3 deletions ui/src/main/webapp/components/SingleInputComponent.jsx
Expand Up @@ -41,7 +41,7 @@ function SingleInputComponent(props) {
disableSearch,
labelField,
autoCompleteFields,
isClearable,
hideClearBtn,
} = controlOptions;

function handleChange(e, obj) {
Expand Down Expand Up @@ -120,6 +120,8 @@ function SingleInputComponent(props) {

const effectiveDisabled = loading ? true : disabled;
const effectivePlaceholder = loading ? _('Loading') : placeholder;
// hideClearBtn=true only passed for OAuth else its undefined
const effectiveIsClearable = effectiveDisabled ? false : !hideClearBtn;

return (
<>
Expand Down Expand Up @@ -153,7 +155,7 @@ function SingleInputComponent(props) {
>
{options && options.length > 0 && options}
</SelectWrapper>
{isClearable !== true ? (
{effectiveIsClearable ? (
<Button
data-test="clear"
appearance="secondary"
Expand Down Expand Up @@ -185,7 +187,7 @@ SingleInputComponent.propTypes = {
referenceName: PropTypes.string,
disableSearch: PropTypes.bool,
labelField: PropTypes.string,
isClearable: PropTypes.bool,
hideClearBtn: PropTypes.bool,
}),
};

Expand Down

0 comments on commit d430c85

Please sign in to comment.