@@ -1084,8 +1084,8 @@ function getModelDirectiveFromInput(element, throwOnMissing = true) {
1084
1084
}
1085
1085
if ( element . getAttribute ( 'name' ) ) {
1086
1086
const formElement = element . closest ( 'form' ) ;
1087
- if ( formElement && formElement . dataset . model ) {
1088
- const directives = parseDirectives ( formElement . dataset . model ) ;
1087
+ if ( formElement && ( 'model' in formElement . dataset ) ) {
1088
+ const directives = parseDirectives ( formElement . dataset . model || '*' ) ;
1089
1089
const directive = directives [ 0 ] ;
1090
1090
if ( directive . args . length > 0 || directive . named . length > 0 ) {
1091
1091
throw new Error ( `The data-model="${ formElement . dataset . model } " format is invalid: it does not support passing arguments to the model.` ) ;
@@ -1195,6 +1195,7 @@ class default_1 extends Controller {
1195
1195
this . renderDebounceTimeout = null ;
1196
1196
this . actionDebounceTimeout = null ;
1197
1197
this . renderPromiseStack = new PromiseStack ( ) ;
1198
+ this . isActionProcessing = false ;
1198
1199
this . pollingIntervals = [ ] ;
1199
1200
this . isWindowUnloaded = false ;
1200
1201
this . originalDataJSON = '{}' ;
@@ -1222,9 +1223,7 @@ class default_1 extends Controller {
1222
1223
if ( ! ( this . element instanceof HTMLElement ) ) {
1223
1224
throw new Error ( 'Invalid Element Type' ) ;
1224
1225
}
1225
- if ( this . element . dataset . poll !== undefined ) {
1226
- this . _initiatePolling ( this . element . dataset . poll ) ;
1227
- }
1226
+ this . _initiatePolling ( ) ;
1228
1227
window . addEventListener ( 'beforeunload' , this . markAsWindowUnloaded ) ;
1229
1228
this . _startAttributesMutationObserver ( ) ;
1230
1229
this . element . addEventListener ( 'live:update-model' , this . handleUpdateModelEvent ) ;
@@ -1234,9 +1233,7 @@ class default_1 extends Controller {
1234
1233
this . _dispatchEvent ( 'live:connect' , { controller : this } ) ;
1235
1234
}
1236
1235
disconnect ( ) {
1237
- this . pollingIntervals . forEach ( ( interval ) => {
1238
- clearInterval ( interval ) ;
1239
- } ) ;
1236
+ this . _stopAllPolling ( ) ;
1240
1237
window . removeEventListener ( 'beforeunload' , this . markAsWindowUnloaded ) ;
1241
1238
this . element . removeEventListener ( 'live:update-model' , this . handleUpdateModelEvent ) ;
1242
1239
this . element . removeEventListener ( 'input' , this . handleInputEvent ) ;
@@ -1387,7 +1384,7 @@ class default_1 extends Controller {
1387
1384
}
1388
1385
this . valueStore . set ( modelName , value ) ;
1389
1386
this . unsyncedInputs . remove ( modelName ) ;
1390
- if ( shouldRender ) {
1387
+ if ( shouldRender && ! this . isActionProcessing ) {
1391
1388
this . _clearWaitingDebouncedRenders ( ) ;
1392
1389
let debounce = this . getDefaultDebounce ( ) ;
1393
1390
if ( options . debounce !== undefined && options . debounce !== null ) {
@@ -1412,6 +1409,7 @@ class default_1 extends Controller {
1412
1409
'Accept' : 'application/vnd.live-component+html' ,
1413
1410
} ;
1414
1411
if ( action ) {
1412
+ this . isActionProcessing = true ;
1415
1413
url += `/${ encodeURIComponent ( action ) } ` ;
1416
1414
if ( this . csrfValue ) {
1417
1415
fetchOptions . headers [ 'X-CSRF-TOKEN' ] = this . csrfValue ;
@@ -1437,6 +1435,9 @@ class default_1 extends Controller {
1437
1435
const reRenderPromise = new ReRenderPromise ( thisPromise , this . unsyncedInputs . clone ( ) ) ;
1438
1436
this . renderPromiseStack . addPromise ( reRenderPromise ) ;
1439
1437
thisPromise . then ( ( response ) => {
1438
+ if ( action ) {
1439
+ this . isActionProcessing = false ;
1440
+ }
1440
1441
if ( this . renderDebounceTimeout ) {
1441
1442
return ;
1442
1443
}
@@ -1665,7 +1666,12 @@ class default_1 extends Controller {
1665
1666
}
1666
1667
this . _updateModelFromElement ( target , 'change' ) ;
1667
1668
}
1668
- _initiatePolling ( rawPollConfig ) {
1669
+ _initiatePolling ( ) {
1670
+ this . _stopAllPolling ( ) ;
1671
+ if ( this . element . dataset . poll === undefined ) {
1672
+ return ;
1673
+ }
1674
+ const rawPollConfig = this . element . dataset . poll ;
1669
1675
const directives = parseDirectives ( rawPollConfig || '$render' ) ;
1670
1676
directives . forEach ( ( directive ) => {
1671
1677
let duration = 2000 ;
@@ -1790,9 +1796,12 @@ class default_1 extends Controller {
1790
1796
const element = this . element ;
1791
1797
this . mutationObserver = new MutationObserver ( ( mutations ) => {
1792
1798
mutations . forEach ( ( mutation ) => {
1793
- if ( mutation . type === 'attributes' && ! element . dataset . originalData ) {
1794
- this . originalDataJSON = this . valueStore . asJson ( ) ;
1795
- this . _exposeOriginalData ( ) ;
1799
+ if ( mutation . type === 'attributes' ) {
1800
+ if ( ! element . dataset . originalData ) {
1801
+ this . originalDataJSON = this . valueStore . asJson ( ) ;
1802
+ this . _exposeOriginalData ( ) ;
1803
+ }
1804
+ this . _initiatePolling ( ) ;
1796
1805
}
1797
1806
} ) ;
1798
1807
} ) ;
@@ -1803,6 +1812,11 @@ class default_1 extends Controller {
1803
1812
getDefaultDebounce ( ) {
1804
1813
return this . hasDebounceValue ? this . debounceValue : DEFAULT_DEBOUNCE ;
1805
1814
}
1815
+ _stopAllPolling ( ) {
1816
+ this . pollingIntervals . forEach ( ( interval ) => {
1817
+ clearInterval ( interval ) ;
1818
+ } ) ;
1819
+ }
1806
1820
}
1807
1821
default_1 . values = {
1808
1822
url : String ,
0 commit comments