facultyai / dash-bootstrap-components

Bootstrap components for Plotly Dash
https://dash-bootstrap-components.opensource.faculty.ai/
Apache License 2.0
1.12k stars 220 forks source link

Enter does not change line inside textarea component #1035

Open athioak7 opened 5 months ago

athioak7 commented 5 months ago

Please fill out the below information as much as possible.

What is happening?

I recently updated my libraries and went from DBC 1.2.0 to 1.5.0. I noticed that I could no longer use 'Enter' inside the textarea to change line, instead I had to use Shift+Enter. When I reverted back to the previous version the issue was fixed. This is also how the textarea responds in the BDC Documentation page.

What should be happening?

On 'Enter' the line should change, as this is the default behavior for a plain textarea.

tcbegley commented 5 months ago

Thanks for submitting this @athioak7

With hindsight, I agree that this doesn't seem quite right, I think the current behaviour was inspired by chat based apps where enter normally sends the message and shift enter allows you to add a new line. Unfortunately a quick search on GitHub suggests there are a number of people out there making use of this behaviour.

Therefore I propose the following, adding a new prop submit_on_enter which one can simply set to False to ensure that pressing Enter creates a new line.

I have implemented this and created a pre-release, feedback is welcome

pip install dash-bootstrap-components==1.6.1rc2

Here's a simple app you can try with.

import dash_bootstrap_components as dbc
from dash import Dash

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

app.layout = dbc.Container(
    dbc.Textarea(id="textarea", submit_on_enter=False), className="p-5"
)

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