From 0d72c147d27f2d75186557a269b0078916c83864 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Jim=C3=A9nez?= Date: Thu, 17 Nov 2022 06:59:43 +0100 Subject: [PATCH] (fix): skip transitions in syncElementState when controller is already connected --- src/controllers/toggler_controller.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/controllers/toggler_controller.js b/src/controllers/toggler_controller.js index 6d5a57f..8f9b303 100644 --- a/src/controllers/toggler_controller.js +++ b/src/controllers/toggler_controller.js @@ -52,7 +52,7 @@ export default class extends Controller { debugAppendActions(this.debugValue); - // setTimeout to avoid transitions in the first load, otherwise + // setTimeout to put this at the end of the event loop - to avoid transitions in the first load, otherwise // statesValueChanged from toggleableTargetConnected happens after setting controller_connected to true setTimeout(() => this.controller_connected = true, 0); } @@ -162,11 +162,9 @@ export default class extends Controller { listened_states.forEach(listener => { let state = this.getStateNameFromListener(listener); let value = this.getStateValue(state); - let skip_transition = !this.controller_connected; + let skip_transition = this.controller_connected; if(state != '' && value != '') { - replaceClasses([element], state, value, skip_transition); - if (['on', 'off'].includes(value)) { replaceClasses([element], state, value, skip_transition);