16
16
* these characters so that it can inject Coder-specific values, so any
17
17
* template literal that uses the character actually needs to double up each
18
18
* of them. There are already a few places in this file where it couldn't be
19
- * avoided, but it will save you some headache.
19
+ * avoided, but avoiding this as much as possible will save you some headache.
20
20
* - All the CSS should be written via custom style tags and the !important
21
21
* directive (as much as that is a bad idea most of the time). We do not
22
22
* control the Angular app, so we have to modify things from afar to ensure
@@ -240,16 +240,12 @@ function setupFormDetection() {
240
240
/** @type {HTMLFormElement | null } */
241
241
const latestForm = document . querySelector ( "web-client-form > form" ) ;
242
242
243
- if ( latestForm === null ) {
244
- formValueFromLastMutation = null ;
245
- return ;
246
- }
247
-
248
243
// Only try to auto-fill if we went from having no form on screen to
249
244
// having a form on screen. That way, we don't accidentally override the
250
245
// form if the user is trying to customize values, and this essentially
251
246
// makes the script values function as default values
252
- if ( formValueFromLastMutation === null ) {
247
+ const mounted = formValueFromLastMutation === null && latestForm !== null ;
248
+ if ( mounted ) {
253
249
autoSubmitForm ( latestForm ) ;
254
250
}
255
251
@@ -364,7 +360,10 @@ function hideFormForInitialSubmission() {
364
360
// and over.
365
361
const rootNode = document . querySelector ( ":root" ) ;
366
362
if ( ! ( rootNode instanceof HTMLHtmlElement ) ) {
367
- styleContainer . innerHTML = "" ;
363
+ // Remove the container entirely because if the browser is busted, who knows
364
+ // if the CSS variables can be applied correctly. Better to have something
365
+ // be a bit more ugly/painful to use, than have it be impossible to use
366
+ styleContainer . remove ( ) ;
368
367
return ;
369
368
}
370
369
@@ -380,6 +379,9 @@ function hideFormForInitialSubmission() {
380
379
// timeout and event listener so that if one triggers, it cancels the other,
381
380
// but having restoreOpacity run more than once is a no-op for right now.
382
381
// Not a big deal if these don't get cleaned up.
382
+
383
+ // Have the form automatically reappear no matter what, so that if something
384
+ // does break, the user isn't left out to dry
383
385
window . setTimeout ( restoreOpacity , 5_000 ) ;
384
386
385
387
/** @type {HTMLFormElement | null } */
0 commit comments