From eba390c6b27e9816ac3efa76f783d34b57b72e01 Mon Sep 17 00:00:00 2001 From: Sahil Batra Date: Fri, 23 Sep 2022 16:00:28 +0530 Subject: [PATCH] settings_org: Convert to number before parseFloat in parse_time_limit. We now first convert the element value to number using "Number()" function and then call parseFloat in parse_time_limit function. If we do not do so and the input element contains something like "24a", it will be converted to 24 after parseFloat and will result in an unexpected behavior where the save-discard widget will not appear if the custom value input is changed from "24" to "24a", since the value is considered as same as before. But now "24a" will return NaN and save-discard widget will appear with save button disabled. --- static/js/settings_org.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/js/settings_org.js b/static/js/settings_org.js index 48fb6dd9cf..1e3f5757da 100644 --- a/static/js/settings_org.js +++ b/static/js/settings_org.js @@ -957,7 +957,7 @@ export function register_save_discard_widget_handlers( }); parse_time_limit = function parse_time_limit($elem) { - return Math.floor(Number.parseFloat($elem.val(), 10).toFixed(1) * 60); + return Math.floor(Number.parseFloat(Number($elem.val()), 10).toFixed(1) * 60); }; function get_complete_data_for_subsection(subsection) {