-
-
Notifications
You must be signed in to change notification settings - Fork 561
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
Markdown element is not updated if it is not displayed (for example in tooltip or tab_panel) #2779
Comments
Thanks for reporting this issue, @me21! That's very strange. It works for labels and HTML, but not for Markdown elements: with ui.textarea() as textarea:
with ui.tooltip():
ui.label().bind_text_from(textarea, 'value')
ui.html().bind_content_from(textarea, 'value')
ui.markdown().bind_content_from(textarea, 'value') I guess the textarea = ui.textarea()
with ui.tabs() as tabs:
one = ui.tab('One')
two = ui.tab('Two')
with ui.tab_panels(tabs, value=one):
with ui.tab_panel(one):
ui.label('First tab')
with ui.tab_panel(two):
ui.label('Second tab')
ui.markdown().bind_content_from(textarea, 'value') Before visiting the second tab for the first time, the Markdown element doesn't receive any updates. This is similar to issue #1869 which has been resolved by re-implementing At the moment I'm not sure how to solve this problem for |
Is it works if we could use the on_hover and on_leave events of the textarea to update the tooltip's content. |
How is ui.markdown translated to the client side? If I understand correctly, ui.html has no such issues, but ui.markdown is rendered to html, so it should behave the same, but it doesn't. |
The ui.markdown function in the ui library is translated to the client side using the marked library, which is a JavaScript library for rendering Markdown to HTML. While making ui.markdown a subclass of ui.html could be an interesting idea, it’s essential to understand their fundamental differences: |
@aniketkumar7 Exactly. Here is the code that runs nicegui/nicegui/elements/markdown.js Lines 16 to 21 in 4d4814e
|
Oh wait, my last comment confused Markdown with Mermaid. A plain |
I think the fundamental problem is that the QTooltip element gets created every time the text area is hovered, while the |
@falkoschindler But why |
I rewritten the
Seems to work. Please feel free to test. |
I realized that by omitting the reference to I will prepare a PR but how do I test that Mermaid and Codehilite work correctly? |
In this PR, |
Mermaid diagrams work now. Please test. |
Description
I'd like to use a textarea to edit Markdown and to display Markdown content in a tooltip:
It mostly works, but the tooltip content is lost if I move the mouse out of textarea and then back. The empty tooltip appears, but after editing the textarea, its contents are updated properly.
The text was updated successfully, but these errors were encountered: