Skip to content

Commit

Permalink
Fixed: Allow decimals for Custom Format size
Browse files Browse the repository at this point in the history
(cherry picked from commit 7f5ddff568ce9f87bd45420cbd36690b190bd633)

Closes #2839
  • Loading branch information
markus101 authored and mynameisbogdan committed Aug 19, 2023
1 parent c10a325 commit 2081f2e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion frontend/src/Components/Form/NumberInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class NumberInput extends Component {
componentDidUpdate(prevProps, prevState) {
const { value } = this.props;

if (value !== prevProps.value && !this.state.isFocused) {
if (!isNaN(value) && value !== prevProps.value && !this.state.isFocused) {
this.setState({
value: value == null ? '' : value.toString()
});
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/Helpers/Props/inputTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const BOOKSHELF = 'bookshelf';
export const KEY_VALUE_LIST = 'keyValueList';
export const MONITOR_BOOKS_SELECT = 'monitorBooksSelect';
export const MONITOR_NEW_ITEMS_SELECT = 'monitorNewItemsSelect';
export const FLOAT = 'float';
export const NUMBER = 'number';
export const OAUTH = 'oauth';
export const PASSWORD = 'password';
Expand Down Expand Up @@ -34,6 +35,7 @@ export const all = [
KEY_VALUE_LIST,
MONITOR_BOOKS_SELECT,
MONITOR_NEW_ITEMS_SELECT,
FLOAT,
NUMBER,
OAUTH,
PASSWORD,
Expand Down
1 change: 1 addition & 0 deletions src/Readarr.Http/ClientSchema/Field.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class Field
public string Section { get; set; }
public string Hidden { get; set; }
public string Placeholder { get; set; }
public bool IsFloat { get; set; }

public Field Clone()
{
Expand Down
5 changes: 5 additions & 0 deletions src/Readarr.Http/ClientSchema/SchemaBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ private static FieldMapping[] GetFieldMapping(Type type, string prefix, Func<obj
field.Hidden = fieldAttribute.Hidden.ToString().FirstCharToLower();
}

if (fieldAttribute.Type is FieldType.Number && propertyInfo.PropertyType == typeof(double))
{
field.IsFloat = true;
}

var valueConverter = GetValueConverter(propertyInfo.PropertyType);

result.Add(new FieldMapping
Expand Down

0 comments on commit 2081f2e

Please sign in to comment.