FlowFuse / node-red-dashboard

https://dashboard.flowfuse.com
Apache License 2.0
184 stars 46 forks source link

ui-text-input should send user input when Enter is pressed #349

Closed colin-grierson closed 10 months ago

colin-grierson commented 10 months ago

Description

Currently the widget does not send user input until the cursor is taken outside of the widget - by tabbing past the last input position or clicking elsewhere. When I first tested my widget, set for time entry, I found this very confusing: I typed my time, pressed Enter - nothing happened. I used the selector popup - chose the time I wanted clicked, double clicked - still nothing happened. Got quite frustrated. Eventually I happened to tab past the seconds and out of the widget - and my time was sent. Similarly for text format the Enter key does nothing. I feel this is very unintuitive and a bad UI. Enter should send the value the user has input (unless it is invalid or incomplete of course)

Epic/Story

No response

Have you provided an initial effort estimate for this issue?

I am no FlowFuse team member

colinl commented 10 months ago

For information, D1 does send on Enter.

Also the Delay field is not yet implemented. That is available in the D1 text in node and says that a message will be sent after a change and configured time of inactivity.

joepavitt commented 10 months ago

Agree entirely, will add to the list. Thanks for raising

joepavitt commented 10 months ago

Implementing this now, and just wanted to share an change I've made to the config vs. Dashboard 1.0:

Image

joepavitt commented 10 months ago

Provides way more customisation and clarity on the behaviour, rather than needing to set delay to 0

colinl commented 10 months ago

Does the comment in yellow mean that if one enters the same value twice then it will only be sent once? I am not sure that is desirable. I think if the user keys in a value then it should be sent even if the value is the same as last time.

joepavitt commented 10 months ago

I am not sure that is desirable. I think if the user keys in a value then it should be sent even if the value is the same as last time.

I have built it to match how Dashboard 1.0 operates.

This prevents a case where, if we have "send on delay" and "send on blur" enabled, only one fires, as realistically that's what the user will want.

I have since updated that yellow comment though, as "send on enter" will always fire, that's an active step taken by the user to send input, so it will abide by that.

colinl commented 10 months ago

What happens if, for example, send on delay 1 second is configured, and the user:

  1. Hits the numeric 1 key
  2. Waits more than 1 second
  3. Erases the '1' and hits the 1 key again
  4. Waits more that one second

I would expect the node to send "1" at point 2 and again at point 4, even though there is no change since the last value sent.

joepavitt commented 10 months ago

Great summary @colinl - that wouldn't work right now in the Open PR, but it's a one line change for it to start working, so will sort that before merging

colinl commented 10 months ago

Perhaps the comment needs adjusting too, to clarify the operation.

joepavitt commented 10 months ago

Done in https://github.com/FlowFuse/node-red-dashboard/pull/365/commits/c2ffaa6fbc59644e76a087af7b0f1aef7bf9cb07

colin-grierson commented 10 months ago

What are the defaults for Delay, Focus Leave and Press Enter options?

colin-grierson commented 10 months ago

Making the action explicit and selectable is a great idea!

joepavitt commented 10 months ago

I think they should be No, Yes, Yes respectively

Good points, I have made it so: https://github.com/FlowFuse/node-red-dashboard/pull/365/commits/ac4cef75bb94c1fce0384a67f065d8a0b92d4634