conversejs / converse.js

Web-based XMPP/Jabber chat client written in JavaScript

Home Page:http://conversejs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Form regression for number fields

JohnXLivingston opened this issue · comments

Describe the bug

Using Converse upstream (v11 unreleased), i have some integer fields in room config that are now displayed using datetime fields:

image

This should be an input type=number (and it was with Converse v10).
Here is a screenshot of the same field in Gajim:

image

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

you can reproduce the same issue by saving 2024-07-02 in the room description (or title), and re-opening the form.