Skip to content

Fix mouse handler binding for talking book tool (BL-16366)#8000

Open
StephenMcConnel wants to merge 1 commit into
Version6.4from
BL-16366-TalkingBookToolNotWorking
Open

Fix mouse handler binding for talking book tool (BL-16366)#8000
StephenMcConnel wants to merge 1 commit into
Version6.4from
BL-16366-TalkingBookToolNotWorking

Conversation

@StephenMcConnel

@StephenMcConnel StephenMcConnel commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Also a bit of cleanup in that general area as well. I'm not sure these changes are needed in 6.5 since the bug was not manifesting there.


This change is Reviewable

@greptile-apps

greptile-apps Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes the talking book tool's mouse handlers being silently dropped whenever the toolbox re-hydrates and replaces its DOM subtree. It also addresses related this-binding bugs in the WebSocket audio-level and mic-error listeners.

  • All toolbar button handlers are migrated from direct jQuery bindings on individual elements to namespaced delegated handlers on $(document), so they survive the toolbox replacing its inner HTML. A wiredPlayer tracking field is added to detect when #player is replaced and re-attach its non-bubbling media events.
  • audioLevelListener and micErrorListener are converted to arrow-function class fields and wrapped with a removeListener/addListener pair, fixing the this-is-undefined bug noted in prior review and preventing duplicate registration.
  • WebSocketManager.removeListener gains an early-return guard so it is safe to call before any listener has been registered for a given context.

Important Files Changed

Filename Overview
src/BloomBrowserUI/bookEdit/toolbox/talkingBook/audioRecording.ts Rewires all toolbar button handlers to use jQuery delegated events on $(document) with namespaced events so they survive toolbox DOM re-hydration; converts audioLevelListener/micErrorListener to arrow-function class fields and adds remove-before-add idempotency; extracts wirePlayerHandlers() and tracks wiredPlayer to re-attach non-bubbling media events after re-hydration.
src/BloomBrowserUI/utils/WebSocketManager.ts Adds an early-return guard in removeListener when clientContext has no registered callbacks, preventing a crash when removeListener is called before any addListener for that context.

Reviews (3): Last reviewed commit: "Fix mouse handler binding for talking bo..." | Re-trigger Greptile

Comment thread src/BloomBrowserUI/bookEdit/toolbox/talkingBook/audioRecording.ts Outdated
Comment thread src/BloomBrowserUI/utils/WebSocketManager.ts Outdated
@StephenMcConnel StephenMcConnel force-pushed the BL-16366-TalkingBookToolNotWorking branch from ad9b2b0 to dd9237c Compare June 24, 2026 21:41
Also a bit of cleanup in that general area as well.  I'm not sure these
changes are needed in 6.5 since the bug was not manifesting there.
@StephenMcConnel StephenMcConnel force-pushed the BL-16366-TalkingBookToolNotWorking branch from dd9237c to 28135c3 Compare June 24, 2026 21:52
@StephenMcConnel StephenMcConnel self-assigned this Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant