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

TextEditor widget doesn't render on FireFox #5600

Closed
maximlt opened this issue Oct 9, 2023 · 1 comment · Fixed by #5609
Closed

TextEditor widget doesn't render on FireFox #5600

maximlt opened this issue Oct 9, 2023 · 1 comment · Fixed by #5609

Comments

@maximlt
Copy link
Member

maximlt commented Oct 9, 2023

Very likely due to changes made in #5511. The error displayed in Firefox's console being:

Error rendering Bokeh items: TypeError: this.shadow_el.getSelection is not a function
    getNativeRange http://localhost:5007/static/extensions/panel/panel.min.js?v=fb7e691caef7a59ca25d1fd9580b7a7d13146fd012a16bf047f631f7bf8a1326:135
    getRange http://localhost:5007/static/extensions/panel/bundled/quillinput/1.3.7/quill.js:3040
    Toolbar http://localhost:5007/static/extensions/panel/bundled/quillinput/1.3.7/quill.js:9401
    emit http://localhost:5007/static/extensions/panel/bundled/quillinput/1.3.7/quill.js:8664
    emit http://localhost:5007/static/extensions/panel/bundled/quillinput/1.3.7/quill.js:1943
    optimize http://localhost:5007/static/extensions/panel/bundled/quillinput/1.3.7/quill.js:4381
    update http://localhost:5007/static/extensions/panel/bundled/quillinput/1.3.7/quill.js:7331
    update http://localhost:5007/static/extensions/panel/bundled/quillinput/1.3.7/quill.js:4403
    deleteAt http://localhost:5007/static/extensions/panel/bundled/quillinput/1.3.7/quill.js:7202
    deleteAt http://localhost:5007/static/extensions/panel/bundled/quillinput/1.3.7/quill.js:4266
    deleteText http://localhost:5007/static/extensions/panel/bundled/quillinput/1.3.7/quill.js:2556
    setContents http://localhost:5007/static/extensions/panel/bundled/quillinput/1.3.7/quill.js:1508
    modify http://localhost:5007/static/extensions/panel/bundled/quillinput/1.3.7/quill.js:1660
    setContents http://localhost:5007/static/extensions/panel/bundled/quillinput/1.3.7/quill.js:1505
    render http://localhost:5007/static/extensions/panel/panel.min.js?v=fb7e691caef7a59ca25d1fd9580b7a7d13146fd012a16bf047f631f7bf8a1326:135
    render http://localhost:5007/static/js/bokeh.min.js?v=c8d721b75531cff043feef626ae0d6e29a26031fae26bba93c1baa962ecfb1b43f211027df3a0cf7772f30afed8c38198d70677b8967e581ca7e605358c68465:547
    render http://localhost:5007/static/extensions/panel/panel.min.js?v=fb7e691caef7a59ca25d1fd9580b7a7d13146fd012a16bf047f631f7bf8a1326:51
    render http://localhost:5007/static/js/bokeh.min.js?v=c8d721b75531cff043feef626ae0d6e29a26031fae26bba93c1baa962ecfb1b43f211027df3a0cf7772f30afed8c38198d70677b8967e581ca7e605358c68465:547
    render http://localhost:5007/static/extensions/panel/panel.min.js?v=fb7e691caef7a59ca25d1fd9580b7a7d13146fd012a16bf047f631f7bf8a1326:51
    render http://localhost:5007/static/js/bokeh.min.js?v=c8d721b75531cff043feef626ae0d6e29a26031fae26bba93c1baa962ecfb1b43f211027df3a0cf7772f30afed8c38198d70677b8967e581ca7e605358c68465:547
    render http://localhost:5007/static/extensions/panel/panel.min.js?v=fb7e691caef7a59ca25d1fd9580b7a7d13146fd012a16bf047f631f7bf8a1326:51
    render_to http://localhost:5007/static/js/bokeh.min.js?v=c8d721b75531cff043feef626ae0d6e29a26031fae26bba93c1baa962ecfb1b43f211027df3a0cf7772f30afed8c38198d70677b8967e581ca7e605358c68465:547
    f http://localhost:5007/static/js/bokeh.min.js?v=c8d721b75531cff043feef626ae0d6e29a26031fae26bba93c1baa962ecfb1b43f211027df3a0cf7772f30afed8c38198d70677b8967e581ca7e605358c68465:218
    f http://localhost:5007/static/js/bokeh.min.js?v=c8d721b75531cff043feef626ae0d6e29a26031fae26bba93c1baa962ecfb1b43f211027df3a0cf7772f30afed8c38198d70677b8967e581ca7e605358c68465:218
    add_document_standalone http://localhost:5007/static/js/bokeh.min.js?v=c8d721b75531cff043feef626ae0d6e29a26031fae26bba93c1baa962ecfb1b43f211027df3a0cf7772f30afed8c38198d70677b8967e581ca7e605358c68465:218
    add_document_from_session http://localhost:5007/static/js/bokeh.min.js?v=c8d721b75531cff043feef626ae0d6e29a26031fae26bba93c1baa962ecfb1b43f211027df3a0cf7772f30afed8c38198d70677b8967e581ca7e605358c68465:225
    g http://localhost:5007/static/js/bokeh.min.js?v=c8d721b75531cff043feef626ae0d6e29a26031fae26bba93c1baa962ecfb1b43f211027df3a0cf7772f30afed8c38198d70677b8967e581ca7e605358c68465:163
    embed_items http://localhost:5007/static/js/bokeh.min.js?v=c8d721b75531cff043feef626ae0d6e29a26031fae26bba93c1baa962ecfb1b43f211027df3a0cf7772f30afed8c38198d70677b8967e581ca7e605358c68465:163
    embed_document http://localhost:5007/issue_texteditor:44
    fn http://localhost:5007/issue_texteditor:47
    fn http://localhost:5007/issue_texteditor:63
    safely http://localhost:5007/static/js/bokeh.min.js?v=c8d721b75531cff043feef626ae0d6e29a26031fae26bba93c1baa962ecfb1b43f211027df3a0cf7772f30afed8c38198d70677b8967e581ca7e605358c68465:234
    fn http://localhost:5007/issue_texteditor:39
    EventListener.handleEvent* http://localhost:5007/issue_texteditor:67
    <anonymous> http://localhost:5007/issue_texteditor:68
@hoxbro
Copy link
Member

hoxbro commented Oct 9, 2023

Likely a race-condition as I can get this to work:

diff --git a/panel/models/quill.ts b/panel/models/quill.ts
index feefe9de..add83e89 100644
--- a/panel/models/quill.ts
+++ b/panel/models/quill.ts
@@ -104,9 +104,13 @@ export class QuillInputView extends HTMLBoxView {
     // Hack Quill and replace document.getSelection with shadow.getSelection
     // see https://stackoverflow.com/questions/67914657/quill-editor-inside-shadow-dom/67944380#67944380
     this.quill.selection.getNativeRange = () => {
-      const selection = (this.shadow_el as any).getSelection();
-      const range = normalizeNative(selection);
-      return range;
+      try {
+        const selection = (this.shadow_el as any).getSelection();
+        const range = normalizeNative(selection);
+        return range;
+      } catch (e) {
+        return null;
+      }
     };
 
     this._editor = (this.shadow_el.querySelector('.ql-editor') as HTMLDivElement)

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 a pull request may close this issue.

2 participants