fix(attestation): improve autosubmit debounce due to tags interactions
This commit is contained in:
parent
2e5ace6488
commit
58064dc6cd
2 changed files with 7 additions and 3 deletions
|
@ -2,17 +2,20 @@ import { isFormInputElement, matchInputElement } from '@coldwired/utils';
|
|||
|
||||
import { ApplicationController } from './application_controller';
|
||||
|
||||
const AUTOSUBMIT_DEBOUNCE_DELAY = 500;
|
||||
const AUTOSUBMIT_DATE_DEBOUNCE_DELAY = 5000;
|
||||
const AUTOSUBMIT_EVENTS = ['input', 'change', 'blur'];
|
||||
|
||||
export class AutosubmitController extends ApplicationController {
|
||||
static targets = ['submitter', 'input'];
|
||||
static values = {
|
||||
debounceDelay: { type: Number, default: 500 }
|
||||
};
|
||||
|
||||
declare readonly submitterTarget: HTMLButtonElement | HTMLInputElement;
|
||||
declare readonly hasSubmitterTarget: boolean;
|
||||
declare readonly inputTarget: HTMLInputElement;
|
||||
declare readonly hasInputTarget: boolean;
|
||||
declare readonly debounceDelayValue: number;
|
||||
|
||||
#dateTimeChangedInputs = new WeakSet<HTMLElement>();
|
||||
|
||||
|
@ -46,8 +49,8 @@ export class AutosubmitController extends ApplicationController {
|
|||
|
||||
matchInputElement(target, {
|
||||
date: () => {},
|
||||
inputable: () => this.debounce(this.submit, AUTOSUBMIT_DEBOUNCE_DELAY),
|
||||
hidden: () => this.debounce(this.submit, AUTOSUBMIT_DEBOUNCE_DELAY)
|
||||
inputable: () => this.debounce(this.submit, this.debounceDelayValue),
|
||||
hidden: () => this.debounce(this.submit, this.debounceDelayValue)
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
= form_for @attestation_template, url: admin_procedure_attestation_template_v2_path(@procedure), html: { multipart: true },
|
||||
data: { turbo: 'true',
|
||||
controller: 'autosubmit attestation',
|
||||
autosubmit_debounce_delay_value: 2000,
|
||||
attestation_logo_attachment_official_label_value: AttestationTemplate.human_attribute_name(:logo_additional),
|
||||
attestation_logo_attachment_free_label_value: AttestationTemplate.human_attribute_name(:logo) } do |f|
|
||||
|
||||
|
|
Loading…
Reference in a new issue