Skip to content

Conversation

@ncornaglia-at-wiris
Copy link
Contributor

…ype icon after reloading website.

Description

This fix implements a fallback for when using textarea as the html element as the parent element of the editor.

  • Related Kanbanize Card: Link to KB-X
  • Related GitHub Issue: Closes #X (Associated GitHub issue, if any)

Type of Change

Please delete options that are not relevant.

  • Feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Chore (non-breaking change that doesn't add any functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (changes to documentation only)
  • Refactoring (non-breaking change that improves the code structure)

Checklist

  • My code follows the style guidelines of this project ( Run yarn lint to check)
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works (if applicable)
  • New and existing unit tests pass locally with my changes

How should be tested? (Manual or Automated Tests)

  • Download the broken demo passed by the client on: https://wiris.slack.com/archives/C01HJ7VQW0N/p1761210173114999?name=C01HJ7VQW0N&perma=1761210173114999

  • Test that after reloading the page, if the first click is done on mathtype, no formula is inserted.

  • On file wiris/index.js paste the modifications from this PR on line 11282:

              // Add null check for latexRange
    
              // This change is needed as when the editor is set in an id of a textarea and not a div, we default to this conditional.
              
              // If this check is not present and we click on the mathtype icon after reloading the page, the equation is not inserted.
              
              if (!latexRange) {
                  // Fallback to regular MathML insertion if latexRange is not available
                  this.insertMathml(mathml);
                  return;
              }
    
  • Reload the page and click on mathtype and try to insert.

  • Manual tests: I have tested this changes manually.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue where formulas fail to insert when clicking the MathType icon after reloading a page that uses a textarea as the editor's parent element. The fix adds a null check for latexRange and falls back to regular MathML insertion when it's unavailable.

Key Changes:

  • Added null check for latexRange in the insertLatex method
  • Implemented fallback to insertMathml when latexRange is not available

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

@xjiang-at-wiris xjiang-at-wiris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked everthing is OK on stagging

@ncornaglia-at-wiris ncornaglia-at-wiris changed the base branch from master to release/v8.14.1 November 3, 2025 12:37
@ncornaglia-at-wiris ncornaglia-at-wiris merged commit 0b170d0 into release/v8.14.1 Nov 4, 2025
15 checks passed
@ncornaglia-at-wiris ncornaglia-at-wiris deleted the fix/insertformula-with-textarea branch November 4, 2025 09:51
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.

4 participants