Skip to content

Fix Translate plugin crash in preview mode#1497

Open
Himanshu4812 wants to merge 1 commit intointernetarchive:masterfrom
Himanshu4812:fix-translate-preview
Open

Fix Translate plugin crash in preview mode#1497
Himanshu4812 wants to merge 1 commit intointernetarchive:masterfrom
Himanshu4812:fix-translate-preview

Conversation

@Himanshu4812
Copy link

Problem

Clicking the Translate button on preview-only (not borrowed) books causes the plugin to crash with:
Cannot read properties of null (reading 'style') and the UI enters an infinite loading state.

This happens because .BRtextLayer does not exist in preview mode, but the plugin assumes it is always present.

Fix

  • Added a null guard in translateRenderedLayer to prevent accessing missing DOM.
  • Added a user-facing alert when attempting to translate a preview-only book.

Result

  • No more console errors.
  • No infinite spinner.
  • Users are informed that borrowing is required.
  • Borrowed books continue to work normally.

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