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

Bugfix: null dereference resizing empty textbox #2234

Closed
wants to merge 1 commit into from

Conversation

cobryan05
Copy link
Contributor

Fixes "TypeError: Cannot read properties of null (reading 'trim')" when resizing an empty textbox. 'value' is an Optional parameter so must be null checked before empty checked.

This causes Sygil-Dev/sygil-webui#656 . It prevents the UI from appearing at all if the input prompt is defaulted to multiline. The fix is a simple null check.

Checklist:

  • [x ] I have performed a self-review of my own code
  • [ x] My code follows the style guidelines of this project
  • I have commented my code in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • [x ] New and existing unit tests pass locally with my changes

Fixes "TypeError: Cannot read properties of null (reading 'trim')"
when resizing an empty textbox. 'value' is an Optional parameter so
must be null checked before empty checked.
@cobryan05 cobryan05 changed the title Buxfix: null dereference resizing empty textbox Bugfix: null dereference resizing empty textbox Sep 12, 2022
@cobryan05
Copy link
Contributor Author

cobryan05 commented Sep 13, 2022

bump I'm not sure if this is waiting for anything (like retriggering the build bot? I don't know how to do that)

@pngwn
Copy link
Member

pngwn commented Sep 13, 2022

Is there a simple reproduction of this issue anywhere? The linked issue doesn't give me much to go by without digging into the source code of the stable-diffusion-webui.

@cobryan05
Copy link
Contributor Author

cobryan05 commented Sep 13, 2022

Reproducing was even simpler than I thought 😆 .

import gradio as gr

with gr.Blocks() as demo:
    box = gr.Textbox(value=None)
demo.launch()

results in

Uncaught (in promise) TypeError: Cannot read properties of null (reading 'trim')
    at text_area_resize (index.843bae95.js:276:14)
    at Object.m (index.843bae95.js:51:78)
    at Object.m (index.843bae95.js:180:13)
    at mount_component (index.aa663a61.js:1039:26)
    at Object.m (index.843bae95.js:421:4)
    at Object.m (Block.25e59696.js:45:18)
    at Object.m (Block.25e59696.js:106:39)
    at mount_component (index.aa663a61.js:1039:26)
    at Object.m (index.843bae95.js:489:4)
    at mount_component (index.aa663a61.js:1039:26)

Not sure exactly how 'None' is getting there in webui, since it should be being set to '' ... but TextBox's value is marked as

value: Optional[str | Callable] = "",

so it shouldn't crash if 'None' is in there

@abidlabs
Copy link
Member

We can always map null to "" in the backend for Textbox, but I think given that other components like Number and Image support being null, I think Textbox should as well @pngwn?

@abidlabs
Copy link
Member

Thank you for the PR @cobryan05. We discussed this and figured it's better to fix this via the backend. We've merged in a fix here: #2264, so this should now work on main. We'll also release a version to pypi by the end of the week.

@abidlabs abidlabs closed this Sep 14, 2022
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 this pull request may close these issues.

3 participants