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
Input field losing focus onChange
w/ custom renderer
#274
Comments
Having the same issue with const renderers = {
/* eslint-disable react/display-name, react/prop-types */
paragraph: ({ children }) => {
const component = children[0].type.displayName === 'ParsedHtml' ? 'div' : 'p';
return <Typography children={children} component={component} gutterBottom />;
},
/* eslint-enable react/display-name, react/prop-types */
}; If I test with a constructor alone like this: const renderers = {
paragraph: 'div',
}; Or like this: const renderers = {
paragraph: Typography,
}; The same node is recycled and my height is left untouched. Browsing the code, the only difference I can notice has to be in |
Ah! Found it while posting the above. /* eslint-disable react/prop-types */
const Paragraph = ({ children }) => {
const component = children[0].type.displayName === 'ParsedHtml' ? 'div' : 'p';
return <Typography children={children} component={component} gutterBottom />;
},
/* eslint-enable react/prop-types */
const renderers = {
paragraph: Paragraph,
}; The renderer simply had to be named. For some reason it doesn't work with shorthand method definitions however. If someone has
|
@pastudan does @angrybacon's suggestion work for you?
I'm not sure what you mean here. react-markdown/src/ast-to-react.js Lines 13 to 35 in c2809c1
caching would be based off the
I'm not sure I follow, you want to do custom rendering, without defining a custom renderer? |
onChange
w/ custom renderer
@pastudan friendly reminder that this is still waiting for additional information |
Unfortunately we removed the code where this was occurring so I can’t test easily. If we do add it back ill give that recommendation a try. Thanks! |
I am going to close this as it’s not actionable for us. If someone runs into this again, please open a new issue with e.g., a codesandbox so we can reproduce it! |
I have a custom renderer that generates an input field (below). When the value of the input is changed, it loses focus because the markdown parser seemingly generates new nodes for the input, as well as the parent. What's weird is that React removes and replaces the nodes despite them being exactly the same except for the input's value.
I am sure there's a way to resolve this by adding a key in the correct place, but I was hoping someone might have an idea of where to start looking? Similar issue in #120 but obviously I can't just disable the inputs here.
The text was updated successfully, but these errors were encountered: