FIX: Allow entering blank values in relative-time-picker (#12193)

FIX: Allow entering blank values in relative-time-picker (#12193)

In certain cases such as the category auto-close hours setting, it makes sense to blank out the relative time picker duration so null is sent to the server to clear the value.

Meta example: How do I disable topic auto close? - support - Discourse Meta

diff --git a/app/assets/javascripts/discourse/app/components/edit-category-settings.js b/app/assets/javascripts/discourse/app/components/edit-category-settings.js
index e7d2914..bfcfa19 100644
--- a/app/assets/javascripts/discourse/app/components/edit-category-settings.js
+++ b/app/assets/javascripts/discourse/app/components/edit-category-settings.js
@@ -135,7 +135,7 @@ export default buildCategoryPanel("settings", {
 
   @action
   onAutoCloseDurationChange(minutes) {
-    let hours = minutes / 60;
+    let hours = minutes ? minutes / 60 : null;
     this.set("category.auto_close_hours", hours);
   },
 });
diff --git a/app/assets/javascripts/discourse/app/components/relative-time-picker.js b/app/assets/javascripts/discourse/app/components/relative-time-picker.js
index 45e04d5..be95d8e 100644
--- a/app/assets/javascripts/discourse/app/components/relative-time-picker.js
+++ b/app/assets/javascripts/discourse/app/components/relative-time-picker.js
@@ -1,5 +1,5 @@
 import discourseComputed, { on } from "discourse-common/utils/decorators";
-
+import { isBlank } from "@ember/utils";
 import Component from "@ember/component";
 import I18n from "I18n";
 import { action } from "@ember/object";
@@ -114,6 +114,9 @@ export default Component.extend({
 
   @discourseComputed("selectedInterval", "duration")
   calculatedMinutes(interval, duration) {
+    if (isBlank(duration)) {
+      return null;
+    }
     duration = parseFloat(duration);
 
     let mins = 0;

GitHub sha: f2126acf

This commit appears in #12193 which was approved by lis2. It was merged by martin.