Giter Site home page Giter Site logo

Comments (3)

TimChild avatar TimChild commented on June 1, 2024 1

@tcbegley, No worries for the delay. Thanks for your considered response!

Yes, I'd noticed that behaviour of input vs textarea in the dcc components, and I understand the hesitation to deviate from the dcc.Textarea behaviour too. At least for my use case, it is just so much more convenient to have the Enter to submit and Shift + Enter for newline (I've tested the pre-release and it works great). For me, that is the behaviour that I expected in the first place from the dcc.Textarea (I first assumed that it was just a multi-line Input), and I was disappointed when I found it did not have that.

On the other hand, I can imagine scenarios when you would want Enter to just be treated as a newline, so there is also an argument for removing the submit on enter from your dbc.Textarea to allow for that and to re-align with the dcc.Textarea behaviour.

My vote would be to go ahead with the Enter for submit and Shift + Enter for newline. It's intuitive, and very helpful when you do want to use that behaviour.
In the case that someone really doesn't want the additional behaviour, could they just apply bootstrap styling to the dcc.Textarea, similar to your recommendation for the dcc.Dropdown? (https://github.com/tcbegley/dash-bootstrap-css)

from dash-bootstrap-components.

tcbegley avatar tcbegley commented on June 1, 2024 1

This is fixed in the latest release

from dash-bootstrap-components.

tcbegley avatar tcbegley commented on June 1, 2024

Hi @TimChild

Thanks for raising this, and sorry for taking some time getting back to you.

This is an interesting one, it seems the default behaviour for HTML forms is that <textarea> will not submit, whether or not shift is pressed, enter will always give a new line. By contrast <input> will submit the form if enter is pressed.

I think your suggestion makes the most sense, shift+enter makes new line, enter by itself submits. My only hesitation is that we would end up diverging slightly from the behaviour of dash-core-components.

I've implemented this change and made it available as a pre-release, I'd be interested to hear how you get on if you have a moment to try it with your app

pip install dash-bootstrap-components==1.5.0rc1

Here's a simple demo app you can try with if you don't have something to hand

import dash_bootstrap_components as dbc
from dash import Dash, html, Input, Output

app = Dash(external_stylesheets=[dbc.themes.BOOTSTRAP])

app.layout = dbc.Container(
    [dbc.Textarea(id="textarea", debounce=True), html.P(id="output")],
    class_name="p-5",
)


@app.callback(Output("output", "children"), Input("textarea", "value"))
def return_value(value):
    return value


if __name__ == "__main__":
    app.run_server(debug=True)

from dash-bootstrap-components.

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.