Form regression for number fields
JohnXLivingston opened this issue · comments
John Livingston commented
Describe the bug
Using Converse upstream (v11 unreleased), i have some integer fields in room config that are now displayed using datetime fields:
This should be an input type=number (and it was with Converse v10).
Here is a screenshot of the same field in Gajim:
Here is the field definition:
<field label="Slow Mode (0=disabled, any positive integer= users can send a message every X seconds.)" var="muc#roomconfig_slow_mode_duration" type="text-single">
<validate xmlns="http://jabber.org/protocol/xdata-validate" datatype="xs:integer">
<range min="0" />
</validate>
<value>5</value>
</field>
The code is in src/utils/html.js
:
} else {
const date = xfield.value ? dayjs(xfield.value) : null;
if (date?.isValid()) {
return tplDateInput({
...default_vals,
...xfield,
value: date.format('YYYY-MM-DDTHH:mm:ss'),
});
}
I don't understand why this is done so. It seems to consider that if the value is a date, the field should be a date.
This has 2 drawbacks:
- if a text field current value is a date, it does not mean that the field should be a date
- it seams "5" is a valid date for dayjs
John Livingston commented
you can reproduce the same issue by saving 2024-07-02
in the room description (or title), and re-opening the form.