From 0d646e738eb47efd4b179fdd7d995e4770844bf4 Mon Sep 17 00:00:00 2001 From: Albert Gasset Date: Wed, 17 Oct 2018 14:37:05 +0200 Subject: [PATCH] MOBILE-2693 data: Do not allow saving blank required textarea fields --- .../mod/data/fields/textarea/providers/handler.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/addon/mod/data/fields/textarea/providers/handler.ts b/src/addon/mod/data/fields/textarea/providers/handler.ts index 6bbc7d9d8..1c1a0bc0d 100644 --- a/src/addon/mod/data/fields/textarea/providers/handler.ts +++ b/src/addon/mod/data/fields/textarea/providers/handler.ts @@ -55,6 +55,11 @@ export class AddonModDataFieldTextareaHandler extends AddonModDataFieldTextHandl // Add some HTML to the text if needed. text = this.textUtils.formatHtmlLines(text); + // WS does not properly check if HTML content is blank when the field is required. + if (this.textUtils.htmlIsBlank(text)) { + text = ''; + } + return [ { fieldid: field.id, @@ -99,11 +104,7 @@ export class AddonModDataFieldTextareaHandler extends AddonModDataFieldTextHandl } const found = inputData.some((input) => { - if (!input.subfield) { - return !!input.value; - } - - return false; + return !input.subfield && this.textUtils.htmlIsBlank(input.value); }); if (!found) {