Fix event handler removal on disconnect #540

Merged
jakubkottnauer merged 2 commits from fix-removeeventhandler-disconnect into main 2024-03-12 05:42:18 +08:00
jakubkottnauer commented 2024-03-12 04:11:20 +08:00 (Migrated from github.com)

Calling .bind(this) always returns a new function, meaning that event handlers registered in connect callbacks were never properly removed in disconnect callbacks. Creating event handlers as arrow functions fixed this and also makes the code simpler.

Calling `.bind(this)` always returns a new function, meaning that event handlers registered in `connect` callbacks were never properly removed in `disconnect` callbacks. Creating event handlers as arrow functions fixed this and also makes the code simpler.
zachgoll (Migrated from github.com) reviewed 2024-03-12 04:27:36 +08:00
zachgoll (Migrated from github.com) left a comment

The code does look nicer, but this introduces some bugs, likely related to Turbo as shown in the video below. In order for tab content to show, a full browser refresh is required:

https://github.com/maybe-finance/maybe/assets/16676157/55c9aa27-74db-4ba9-ba7d-2a36201dcc19

The code does look nicer, but this introduces some bugs, likely related to Turbo as shown in the video below. In order for tab content to show, a full browser refresh is required: https://github.com/maybe-finance/maybe/assets/16676157/55c9aa27-74db-4ba9-ba7d-2a36201dcc19
jakubkottnauer commented 2024-03-12 05:12:51 +08:00 (Migrated from github.com)

@zachgoll Well spotted! I have pushed a fix, the issue was that the updateClasses method in tab-controller was receiving the turbo event as the first argument (but it expected the tab to select).

@zachgoll Well spotted! I have pushed a fix, the issue was that the `updateClasses` method in `tab-controller` was receiving the turbo event as the first argument (but it expected the tab to select).
zachgoll commented 2024-03-12 05:42:07 +08:00 (Migrated from github.com)

@jakubkottnauer awesome, looks good now!

@jakubkottnauer awesome, looks good now!
Sign in to join this conversation.