Markdown editor losing focus randomly while typing
martons opened this issue · 10 comments
Hello folks. I am working in a Contentful app that renders an Entry editor containing some Markdown editors. At first sight everything works fine but I detected that, while typing, focus is randomly lost. I say randomly because sometimes that happens when data is saved, but that's not always the case.
Initially I thought it could be a re-rendering issue or something else inside the app causing this behaviour, but I removed every single element but the Markdown editor and the experience was exactly the same.
I am copying below the relevant lines from my code. I would say that the only thing to highlight is how I wrap the sdk
object to make the editor work inside the Entry
location. I found this trick in another thread in this repo but maybe for this specific case something else might be required.
[...]
import { MarkdownEditor } from '@contentful/field-editor-markdown';
import 'codemirror/lib/codemirror.css';
[...]
const getFieldExtensionForLocaleSDK = (locale: string): FieldExtensionSDK => {
const sdk: FieldExtensionSDK = {
...props.sdk,
field: field.getForLocale(locale),
} as FieldExtensionSDK;
return sdk;
};
[...]
<MarkdownEditor sdk={getFieldExtensionForLocaleSDK(locale)} isInitiallyDisabled={false} />
From what I can say from my debugging sessions is that the issue is generated by an onkeypress
event attached to the PRE element with class name CodeMirror-line
inside the editor, but I have no idea on how to change this behaviour.
Any hint will be highly appreciated.
Thanks in advance,
David Martos
I have the same problem here. Any news about this one?
This is happening to me, too. It would be nice if anyone from the Contentful team at least acknowledged they actively check the issues in GitHub.
Marking issue as stale since there was no activity for 30 days
Commenting to un-stale the thread
Marking issue as stale since there was no activity for 30 days
un-staling it again, but I don't think I will get any news on the topic :(
Marking issue as stale since there was no activity for 30 days
Is there an update to this? I would love to use the markdown editor in an extension but it's just not usable like this :(
Marking issue as stale since there was no activity for 30 days
Hey,
we just released a fix for this issue with @contentful/field-editor-markdown@1.5.3