Problem/Motivation
When duplicating a webform whose title is equivalent to an existing machine name, we get an error on saving and have to explicitly change the machine name to something else.
See screenshot that says "Duplicate 'Contact Us' form":
- In D10.1, the prospective machine name for the new form would auto-change as we typed a new title, so if we change this to "Contact Sales, the machine name automatically changes to "contact_sales".
- In D10.2, this does not happen. The machine name stays "contact_us" and if we press "Save" immediately, this gives an error.
Cause: in
π
Machine name generation is way too slow
Fixed
, the code of machine-name.js changed.
- I cannot tell you exactly what this particular piece of code does, but it results in
$target[0].value
being set with a value, while it was empty just before. This does not happen in D10.1.
- A little later on (line 182 in the linked version of machine-name.js),
$target[0].value
is interpreted as "the machine name was already set, so this is a pre-existing existing thing, we are not going to attach the code that changes the machine name as the user types".
Steps to reproduce
- Have an existing form with machine name "contact" and title "Contact"
- Visit the "duplicate" screen and type "Contact someone" in the title. (See that the machine name does not change.)
- Save form without doing anything else -- get error.
Note the following do not immediately reproduce the bug:
- An existing form with machine name "contact" and title "Contact Us" -- the first time.
- Reason: upon opening the duplication screen, the assigned machine name is "contact_us", which likely does not exist yet.
- If the user does not pay any attention to the machine name before saving, then they will only get an error the second time the form is duplicated -- because then the machine name "contact_us" already exists.
- A webform template -- the first time.
- In the same way, the second time that a template gets saved into a 'real' form, it will have an already-existing machine name and an unsuspecting user gets an error.
Proposed resolution
The simple solution: empty out the original title in the "duplicate" form.
This way, auto-changing the machine name is restored.
Disadvantage / possible UX regression: the user needs to completely type the new title again -- or copypaste it from the webpage title which says "Duplicate 'TEMPLATE-TITLE' form"
The more complicated solution: change code so that the JS still attaches the machine-name-auto-change behavior even though the title is empty now.
I'm mentioning this in case the simple solution is considered a big UX regression. IMHO it is less of a regression than the current situation, which can lead to inadventently saving a new webform with a totally different/unintended machine name, if a user doesn't pay attention to changing the machine name to the new title. (And users have never been taught to pay attention to this.)
Remaining tasks
Decision on whether this is a UX regression.
Review.
User interface changes
For the simple solution: the user needs to completely type the new title again in a webform that is going to be duplicated / created from a template.