rich-markdown-editor
rich-markdown-editor copied to clipboard
Support host applications using HashRouter
If I use the HashRouter, instead of the BroswerRouter, I get URLs like "http://localhost:3000/#/collections/new_collection/items/pippo" that break RichMarkdownEditor.scrollToAnchor:
index.tsx:405 Attempted to scroll to invalid hash: #/collections/new_collection/items/pippo DOMException: Failed to execute 'querySelector' on 'Document': '#/collections/new_collection/items/pippo' is not a valid selector.
at RichMarkdownEditor.scrollToAnchor (http://localhost:3000/static/js/0.chunk.js:239564:32)
at RichMarkdownEditor.componentDidMount (http://localhost:3000/static/js/0.chunk.js:239373:10)
at commitLifeCycles (http://localhost:3000/static/js/0.chunk.js:200875:26)
at commitLayoutEffects (http://localhost:3000/static/js/0.chunk.js:203847:11)
at HTMLUnknownElement.callCallback (http://localhost:3000/static/js/0.chunk.js:181377:18)
at Object.invokeGuardedCallbackDev (http://localhost:3000/static/js/0.chunk.js:181426:20)
at invokeGuardedCallback (http://localhost:3000/static/js/0.chunk.js:181479:35)
at commitRootImpl (http://localhost:3000/static/js/0.chunk.js:203589:13)
at unstable_runWithPriority (http://localhost:3000/static/js/0.chunk.js:247300:16)
at runWithPriority$1 (http://localhost:3000/static/js/0.chunk.js:192264:14)
at commitRoot (http://localhost:3000/static/js/0.chunk.js:203431:7)
at finishSyncRender (http://localhost:3000/static/js/0.chunk.js:202848:7)
at performSyncWorkOnRoot (http://localhost:3000/static/js/0.chunk.js:202834:11)
at http://localhost:3000/static/js/0.chunk.js:192318:28
at unstable_runWithPriority (http://localhost:3000/static/js/0.chunk.js:247300:16)
at runWithPriority$1 (http://localhost:3000/static/js/0.chunk.js:192264:14)
at flushSyncCallbackQueueImpl (http://localhost:3000/static/js/0.chunk.js:192313:11)
at flushSyncCallbackQueue (http://localhost:3000/static/js/0.chunk.js:192301:7)
at scheduleUpdateOnFiber (http://localhost:3000/static/js/0.chunk.js:202241:13)
at dispatchAction (http://localhost:3000/static/js/0.chunk.js:196821:9)
at http://localhost:3000/static/js/main.chunk.js:1604:11
Hi @lordkada – I can't class this as a bug in the editor as the editor is using fragments as you would expect them to be used – to identify a heading/section in a page. It sounds like your host application is "abusing" fragments for it's entire routing system, which is not really best practice.
I don't have time to address this usecase, however if you have suggestions on how it might be changed to support your router and want to PR a solution I'm very open to that.