@@ -223,33 +223,49 @@ export class AddIdeaComponent {
223223 }
224224
225225 updateText ( text : any ) {
226- this . ideaForm . controls [ 'description' ] . markAsUntouched ( ) ;
227- this . ideaForm . controls [ 'description' ] . setValue ( text ) ;
228-
229- if ( text && text . trim ( ) . length > 0 ) {
230- if ( ! this . autosaveSubscription || this . autosaveSubscription . closed ) {
231- this . startAutosave ( ) ;
226+ /**
227+ * Quick fix for the editor to not fire updateText
228+ * when the editor is opened and the text is empty.
229+ *
230+ * @todo : Think of a better way to handle this.
231+ */
232+ if ( this . app . addIdea . value ) {
233+ this . ideaForm . controls [ 'description' ] . markAsUntouched ( ) ;
234+ this . ideaForm . controls [ 'description' ] . setValue ( text ) ;
235+
236+ if ( text && text . trim ( ) . length > 0 ) {
237+ if ( ! this . autosaveSubscription || this . autosaveSubscription . closed ) {
238+ this . startAutosave ( ) ;
239+ }
232240 }
233241 }
234242 }
235243
236244 ngModelChange ( key : string , value : number | string | null ) {
237- this . ideaForm . controls [ key ] . markAsUntouched ( ) ;
238-
239- if (
240- key === 'statement' &&
241- value &&
242- value . toString ( ) . trim ( ) . length > 0 &&
243- ( ! this . autosaveSubscription || this . autosaveSubscription . closed )
244- ) {
245- this . startAutosave ( ) ;
246- }
245+ /**
246+ * Quick fix for the editor to not fire updateText
247+ * when the editor is opened and the text is empty.
248+ *
249+ * @todo : Think of a better way to handle this.
250+ */
251+ if ( this . app . addIdea . value ) {
252+ this . ideaForm . controls [ key ] . markAsUntouched ( ) ;
253+
254+ if (
255+ key === 'statement' &&
256+ value &&
257+ value . toString ( ) . trim ( ) . length > 0 &&
258+ ( ! this . autosaveSubscription || this . autosaveSubscription . closed )
259+ ) {
260+ this . startAutosave ( ) ;
261+ }
247262
248- if ( value !== null && key === 'demographics_age' ) {
249- if ( ( value as number ) > this . AGE_LIMIT ) {
250- this . ideaForm . controls [ key ] . setValue ( this . AGE_LIMIT ) ;
251- } else if ( ( value as number ) < 0 ) {
252- this . ideaForm . controls [ key ] . setValue ( 0 ) ;
263+ if ( value !== null && key === 'demographics_age' ) {
264+ if ( ( value as number ) > this . AGE_LIMIT ) {
265+ this . ideaForm . controls [ key ] . setValue ( this . AGE_LIMIT ) ;
266+ } else if ( ( value as number ) < 0 ) {
267+ this . ideaForm . controls [ key ] . setValue ( 0 ) ;
268+ }
253269 }
254270 }
255271 }
0 commit comments