FlowFuse / node-red-dashboard

https://dashboard.flowfuse.com
Apache License 2.0
204 stars 48 forks source link

Text Input node set for 'datetime picker' with a value passed to the input node breaks the picker #1409

Open gfinleyg opened 3 weeks ago

gfinleyg commented 3 weeks ago

Current Behavior

Inputs to a Text Input node that is set to datetime picker aren't displayed.

Expected Behavior

Passing a valid JavaScript Date number should change the date and time set in the field.

Steps To Reproduce

Attach a function block outputting msg.payload = 1728932496400 to the input of a Text Input node with it's mode set to datetime picker.

Environment

Have you provided an initial effort estimate for this issue?

I am not a FlowFuse team member

gfinleyg commented 3 weeks ago

The node's behavior is broken with this setup too, if you try to change any of the date/time fields or select using the calendar, it goes back to a blank value as soon as you mouse-hover over the field again.

bartbutenaers commented 2 weeks ago

@gfinleyg

gfinleyg commented 2 weeks ago

I was trying it with a numerical value of 1728932496400, it's good to note that the string "1728932496400" doesn't work either.

I also tried a few of the Javascript "new Date()" formats, with no luck.

It looks like using the format that you saw in the dev tools console log works and doesn't leave the tool broken in Firefox. It appears that the .toISOString() function would get that output, but none of the other formats will work out of the box and .toISOString() isn't available in my instance of Node-Red for function nodes.

colinl commented 2 weeks ago

I think the idea is that you have to feed it with a value in the same format as the output. If you want it to take a js timestamp then it has to know which timezone you want, which can be problematic. As it is, it is timezone agnostic. D1 is a bit of a mess with time/date pickers because of this. Edit: A mess because it tries to allow for timezone.

gfinleyg commented 2 weeks ago

@colinl That makes sense, but it isn't returned in that format and there isn't any documentation of how it should work in https://dashboard.flowfuse.com/nodes/widgets/ui-text-input.html. A working datetime output looks like: 12/01/2024, 01:01 AM not "yyyy-MM-ddThh:mm"

I'm not sure where to get access to the developer tools console log mentioned earlier, so I had no idea that was the format required for this to work.

I figured the varying format possibilities could be a problem which was why I started with the numerical ms since the beginning of the Epoch input.

colinl commented 2 weeks ago

but it isn't returned in that format

It is for me. image

gfinleyg commented 2 weeks ago

Fair, I was looking at the output on the dashboard rather than a debug node. I suppose not using the ms since the beginning of the epoch also allows usage of dates before 1970 which could have some use-cases.

Looks like you can use negative numbers to set dates prior to 1970, so that last statement isn't as important.