File tree 3 files changed +1245
-1000
lines changed
3 files changed +1245
-1000
lines changed Original file line number Diff line number Diff line change 39
39
"dayjs" : " ^1.11.10" ,
40
40
"emoji-mart" : " ^5.5.2" ,
41
41
"javascript-time-ago" : " ^2.5.9" ,
42
- "lit" : " ^3.1.2"
42
+ "lit" : " ^3.1.2" ,
43
+ "lodash-es" : " ^4.17.21"
43
44
},
44
45
"devDependencies" : {
46
+ "@types/lodash-es" : " ^4.17.12" ,
45
47
"lit-analyzer" : " ^2.0.3"
46
48
}
47
49
}
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { consume } from '@lit/context';
3
3
import { css , html , LitElement } from 'lit' ;
4
4
import { property , state } from 'lit/decorators.js' ;
5
5
import { createRef , Ref , ref } from 'lit/directives/ref.js' ;
6
+ import { debounce } from 'lodash-es' ;
6
7
import {
7
8
allowAnonymousCommentsContext ,
8
9
baseUrlContext ,
@@ -254,6 +255,13 @@ export class BaseForm extends LitElement {
254
255
` ;
255
256
}
256
257
258
+ private debouncedSubmit = debounce ( ( data : Record < string , unknown > ) => {
259
+ const event = new CustomEvent ( 'submit' , {
260
+ detail : data ,
261
+ } ) ;
262
+ this . dispatchEvent ( event ) ;
263
+ } , 300 ) ;
264
+
257
265
onSubmit ( e : Event ) {
258
266
e . preventDefault ( ) ;
259
267
const form = e . target as HTMLFormElement ;
@@ -270,10 +278,7 @@ export class BaseForm extends LitElement {
270
278
} )
271
279
) ;
272
280
273
- const event = new CustomEvent ( 'submit' , {
274
- detail : data ,
275
- } ) ;
276
- this . dispatchEvent ( event ) ;
281
+ this . debouncedSubmit ( data ) ;
277
282
}
278
283
279
284
resetForm ( ) {
You can’t perform that action at this time.
0 commit comments