Skip to content

Commit c5c1d97

Browse files
committed
prevent multiple checkbox clicks for todos
1 parent 71aa8ef commit c5c1d97

1 file changed

Lines changed: 19 additions & 14 deletions

File tree

assets/js/suggested-task.js

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -260,12 +260,11 @@ prplSuggestedTask = {
260260
const newStatus =
261261
'publish' === postData.status ? 'trash' : 'publish';
262262

263-
// Disable the checkbox for RR tasks.
264-
if ( 'user' !== taskProviderId && 'trash' === newStatus ) {
265-
el.querySelector(
266-
'.prpl-suggested-task-checkbox'
267-
).setAttribute( 'disabled', 'disabled' );
268-
}
263+
// Disable the checkbox for RR tasks, to prevent multiple clicks.
264+
el.querySelector( '.prpl-suggested-task-checkbox' ).setAttribute(
265+
'disabled',
266+
'disabled'
267+
);
269268

270269
post.set( 'status', newStatus )
271270
.save()
@@ -280,14 +279,10 @@ prplSuggestedTask = {
280279
if ( 'trash' === newStatus ) {
281280
el.setAttribute( 'data-task-action', 'celebrate' );
282281
if ( 'user' === taskProviderId ) {
283-
const delay = eventPoints ? 2000 : 0;
284-
285282
// Set class to trigger strike through animation.
286-
if ( 0 < eventPoints ) {
287-
el.classList.add(
288-
'prpl-suggested-task-celebrated'
289-
);
290-
}
283+
el.classList.add(
284+
'prpl-suggested-task-celebrated'
285+
);
291286

292287
setTimeout( () => {
293288
// Move task from published to trash.
@@ -303,7 +298,12 @@ prplSuggestedTask = {
303298
window.dispatchEvent(
304299
new CustomEvent( 'prpl/grid/resize' )
305300
);
306-
}, delay );
301+
302+
// Remove the disabled attribute for user tasks, so they can be clicked again.
303+
el.querySelector(
304+
'.prpl-suggested-task-checkbox'
305+
).removeAttribute( 'disabled' );
306+
}, 2000 );
307307
} else {
308308
/**
309309
* Strike completed tasks and remove them from the DOM.
@@ -349,6 +349,11 @@ prplSuggestedTask = {
349349
window.dispatchEvent(
350350
new CustomEvent( 'prpl/grid/resize' )
351351
);
352+
353+
// Remove the disabled attribute for user tasks, so they can be clicked again.
354+
el.querySelector(
355+
'.prpl-suggested-task-checkbox'
356+
).removeAttribute( 'disabled' );
352357
}
353358
} );
354359
} );

0 commit comments

Comments
 (0)