Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javascript error after closing live preview pane; subsequent link editing is glitched #299

Closed
croxton opened this issue Feb 2, 2021 · 1 comment
Labels

Comments

@croxton
Copy link
Contributor

croxton commented Feb 2, 2021

Description

When the Live Preview panel is closed, an Uncaught TypeError is thrown.

When you try to subsequently edit existing links within a Redactor field (with the preview pane closed), the context toolbar ('Edit link', 'Unlink') does not appear. There may be other effects as well once the error has been triggered - we have received reports that adding new links may cause existing links to disappear, when you have multiple Redactor fields in a Matrix field - but I have not been able to reproduce.

Uncaught TypeError: Cannot read property 'createDocumentFragment' of undefined
    at xe (jquery.js? [sm]:5004)
    at Re (jquery.js? [sm]:6073)
    at b.fn.init.append (jquery.js? [sm]:6264)
    at b.fn.init.b.each.b.fn.<computed> [as appendTo] (jquery.js? [sm]:6398)
    at Object.handler (RedactorOverrides.js:410)
    at s.constructor.trigger (garnish.js? [sm]:840)
    at s.constructor.close (Preview.js:385)
    at s.constructor.<anonymous> (garnish.js? [sm]:893)
    at HTMLButtonElement.o (jquery.js? [sm]:10771)
    at HTMLButtonElement.dispatch (jquery.js? [sm]:5429)

As you can see the error relates to this line:

$(this.$contextbar.get()).appendTo($target.get(0));

Steps to reproduce

  1. Create a Redactor field using the 'Default' config, and attach to a new Section with no other fields
  2. Create a new entry and add a link to the Redactor field
  3. Click 'Preview'
  4. Close the 'Close Preview' button
  5. Note that clicking the link you created no longer shows the contextual toolbar

Additional info

  • Craft version: 3.6.0.1
  • PHP version: 7.4.12
  • Database driver & version: 5.7.12
  • Plugins & versions: Redactor 2.8.5 (tested with no other plugins installed)
@croxton croxton added the bug label Feb 2, 2021
@croxton
Copy link
Contributor Author

croxton commented Feb 2, 2021

This seems to fix it:

var detachLivePreview = () => {
   var $target = this.toolbar.getTargetElement();
   if ($target.length) {
      $(this.$contextbar.get(0)).appendTo($target.get(0));
   }
   this.livePreview = false;
}

andris-sevcenko pushed a commit that referenced this issue Aug 2, 2021
Mark resolutions:
Resolve #282
Resolve #299
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant