Giter Site home page Giter Site logo

Disable auto submit about streamlit-ace HOT 8 CLOSED

okld avatar okld commented on June 15, 2024
Disable auto submit

from streamlit-ace.

Comments (8)

okld avatar okld commented on June 15, 2024

Hello @niyue,

Using Command + Enter is indeed not supported currently due to how the component was implemented.
For your specific use case, you may try to create a streamlit button to manually apply/run your SQL query once you've finished inputting it.

from streamlit-ace.

niyue avatar niyue commented on June 15, 2024

Hi @Ghasel, thanks for the reply. I wonder how I can prevent the streamlit-ace component from automatically submit the query? I am not sure if this a question for streamlit in general or it is a specific streamlit-ace question, but currently it seems any typing in the ace component will trigger the refresh of the page, and I have no idea how to avoid this after checking out the options of the ace component.

from streamlit-ace.

okld avatar okld commented on June 15, 2024

Yes, for now there is no way to avoid the app to refresh when you input data with ace.
And from what you've said, I suppose each time the app refreshes, it runs your SQL query. As I said in my previous reply, instead of running your query each time the app reruns, you can run it only when you press a streamlit button, like so:

query = st_ace(language="sql")

if st.button("Run query"):
    # Here is your logic to apply your SQL query
    execute_query(query)

from streamlit-ace.

niyue avatar niyue commented on June 15, 2024

Thank you. I will give it a try.

from streamlit-ace.

okld avatar okld commented on June 15, 2024

Hello @niyue,

I've released a new version with an auto_update parameter. By setting it to False, you can use Command + Enter to manually update Streamlit.

from streamlit-ace.

niyue avatar niyue commented on June 15, 2024

@Ghasel thanks for the update.

I gave it a try today, and found some issues, not really sure if I used it incorrect.

st_ace(
        ...
        min_lines=st.sidebar.slider("Min lines", value=10),
        # max_lines=st.sidebar.slider("Max lines", value=20),
        key="ace-editor",
        auto_update=False,
    )

I added the auto_update parameter and set it to False, but I found:

  1. the prompt under the editor is Press Ctrl+Enter to apply while I use Safari under macOS, which I expect it to be Press Cmd+Enter to apply like regular text box
  2. When I use vim or emacs keybindings, it works when I press Cmd + Enter, and the change is applied as expected
  3. When I use vscode or sublime keybindings, and press Cmd + Enter, the change is not applied, instead, it works like Enter is pressed and a new line is inserted into the editor
  4. Whatever keybinding I use, Ctrl + Enter doesn't work (and I assume it is not expected to work but the prompt is not correct as I said in issue no. 1)

from streamlit-ace.

okld avatar okld commented on June 15, 2024

@niyue Thanks for those details! Everything should work now with the version 0.0.3.

from streamlit-ace.

xiashuqin89 avatar xiashuqin89 commented on June 15, 2024

i have try to use auto_update parameters, but it still not work, do you have method to hide the submit button?

from streamlit-ace.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.