From fea66cb7bccc7e94523614db38b157fa38f55ea5 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sat, 10 Dec 2022 16:04:06 -0800 Subject: [PATCH] Fixed: Quality cutoff updating in UI when adding/removing qualities Closes #5290 --- .../Components/Form/EnhancedSelectInput.js | 38 ++++++++++++------- .../Form/HintedSelectInputSelectedValue.js | 14 ++++--- .../Form/RootFolderSelectInputOption.js | 2 +- 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/frontend/src/Components/Form/EnhancedSelectInput.js b/frontend/src/Components/Form/EnhancedSelectInput.js index 709eb740c..4df54092c 100644 --- a/frontend/src/Components/Form/EnhancedSelectInput.js +++ b/frontend/src/Components/Form/EnhancedSelectInput.js @@ -113,10 +113,12 @@ class EnhancedSelectInput extends Component { this._scheduleUpdate(); } - if (!Array.isArray(this.props.value) && prevProps.value !== this.props.value) { - this.setState({ - selectedIndex: getSelectedIndex(this.props) - }); + if (!Array.isArray(this.props.value)) { + if (prevProps.value !== this.props.value || prevProps.values !== this.props.values) { + this.setState({ + selectedIndex: getSelectedIndex(this.props) + }); + } } } @@ -332,6 +334,11 @@ class EnhancedSelectInput extends Component { const isMultiSelect = Array.isArray(value); const selectedOption = getSelectedOption(selectedIndex, values); + let selectedValue = value; + + if (!values.length) { + selectedValue = isMultiSelect ? [] : ''; + } return (
@@ -372,15 +379,17 @@ class EnhancedSelectInput extends Component { onPress={this.onPress} > { - isFetching && + isFetching ? + /> : + null } { - !isFetching && + isFetching ? + null : @@ -400,7 +409,7 @@ class EnhancedSelectInput extends Component { onPress={this.onPress} > { - isFetching && + isFetching ? + /> : + null } { - !isFetching && + isFetching ? + null : @@ -505,7 +516,7 @@ class EnhancedSelectInput extends Component { { - isMobile && + isMobile ? - + : + null }
); diff --git a/frontend/src/Components/Form/HintedSelectInputSelectedValue.js b/frontend/src/Components/Form/HintedSelectInputSelectedValue.js index 07f6c9e25..a3fecf324 100644 --- a/frontend/src/Components/Form/HintedSelectInputSelectedValue.js +++ b/frontend/src/Components/Form/HintedSelectInputSelectedValue.js @@ -24,7 +24,7 @@ function HintedSelectInputSelectedValue(props) { >
{ - isMultiSelect && + isMultiSelect ? value.map((key, index) => { const v = valuesMap[key]; return ( @@ -32,26 +32,28 @@ function HintedSelectInputSelectedValue(props) { {v ? v.value : key} ); - }) + }) : + null } { - !isMultiSelect && value + isMultiSelect ? null : value }
{ - hint != null && includeHint && + hint != null && includeHint ?
{hint} -
+ : + null } ); } HintedSelectInputSelectedValue.propTypes = { - value: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number]))]).isRequired, + value: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number]))]).isRequired, values: PropTypes.arrayOf(PropTypes.object).isRequired, hint: PropTypes.string, isMultiSelect: PropTypes.bool.isRequired, diff --git a/frontend/src/Components/Form/RootFolderSelectInputOption.js b/frontend/src/Components/Form/RootFolderSelectInputOption.js index cdbd44db0..3197ba875 100644 --- a/frontend/src/Components/Form/RootFolderSelectInputOption.js +++ b/frontend/src/Components/Form/RootFolderSelectInputOption.js @@ -67,7 +67,7 @@ RootFolderSelectInputOption.propTypes = { id: PropTypes.string.isRequired, value: PropTypes.string.isRequired, freeSpace: PropTypes.number, - isMissing: PropTypes.boolean, + isMissing: PropTypes.bool, seriesFolder: PropTypes.string, isMobile: PropTypes.bool.isRequired, isWindows: PropTypes.bool