Skip to content

Commit

Permalink
(fix): skip transitions in syncElementState when controller is alread…
Browse files Browse the repository at this point in the history
…y connected
  • Loading branch information
davidjr82 committed Nov 17, 2022
1 parent e5e256d commit 0d72c14
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/controllers/toggler_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 0d72c14

Please sign in to comment.