Commit Graph

2 Commits

Author SHA1 Message Date
Olivier Gayot 348195b4d6 form: disable Done button on validation failure of a child form
When the validation of a field fails in a form, we disable the Done
button. With child forms, however, it did not work because they have
their own set of hidden buttons ; that are not the ones the users
interacts with.

This patch makes parent forms recurse on the child forms when checking
if any field is in error. Also, when a child form undertakes validation,
it now propagates to the parent, so that the done button can be
immediately enabled/disabled.

Having a validation error in a child form that is not currently enabled
should not prevent the user from moving forward, so we disable recursion
for child forms that are disabled.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
2022-06-09 11:28:36 +02:00
Michael Hudson-Doyle 3bdca52ed4 Tweak the adjustment of table columns widths for cells with colspan > 1
When allocating space for a cell colspan > 1, preferentially
allocate space to columns that have no colspan = 1 cells. If you
have content like this (content padded to 10 and 20 chars to make
calculations easier):

[[(2, "longer content567890"), "shorter890"],
 ["shorter890", (2, "longer content567890")]]

Taking only colspan = 1 cells into account, the widths of the
columns are (10, 0, 10).

To fit the first longer content in, the current algorithm expands
the first two columns equally, so the widths become (15, 5, 10).

Then to fit the second longer content in, the second two columns
are widened equally (or nearly so), resulting in final widths
of (15, 8, 12) and a table layout like this:

    +-------------------------+--------------+
    | longer content567890    | shorter890   |
    +-----------------+-------+--------------+
    | shorter890      | longer content567890 |
    +-----------------+----------------------+

which is bizarrely asymmetrical given the input and wider than it
needs to be.

If instead we preferentially widen columns that have no width
from colspan = 1 columns, we get this layout:

    +----------------------+------------+
    | longer content567890 | shorter890 |
    +------------+---------+------------+
    | shorter890 | longer content567890 |
    +------------+----------------------+

Which is much more in line with my expectations.
2019-05-30 15:10:34 +12:00