Page MenuHomePhorge

“Form data changed” confirmation is shown after even read-only keyboard interaction
Open, Needs TriagePublic

Description

The “Form data may have changed. Are you sure you want to close this dialog?” confirmation dialog (T15034) is shown whenever any key has been pressed in the dialog, including keys which do not change anything, including Shift+Tab, Ctrl+A, Ctrl+C. (But excluding arrows and Tab, those seem to be ignored.) Selecting using mouse and copying via a right-click menu does not trigger the confirmation. And even right-clicking and pasting a text into the dialog (into some other dialog which is not read-only) does not trigger it, allowing me to close without confirmation.

Repro:

  1. Go to a Diffusion repository page.
  2. Click the green Clone button.
  3. In the dialog, click an edit box.
  4. Press Ctrl+C to copy the URL.
  5. Press Esc to close the dialog.

What happens:
A confirmation dialog “Form data may have changed. Are you sure you want to close this dialog?” appears.

What should happen instead:
Nothing should be shown; by pressing Ctrl+C, I didn’t change any form data.

Event Timeline

Probably something here should be expanded to check if the form contains at least a visible input without read-only

https://we.phorge.it/source/phorge/browse/master/webroot/rsrc/externals/javelin/lib/Workflow.js$409-418

In jQuery it would be something like:

var $someConcreteInputs = $(form).find('input').not('[readonly]');
if(  $someConcreteInputs.length > 0 ) {
    // This is a real form
}

I don't know how to do the same thing with Javelin but it should be easy I think. Patch welcome

Yeah, that might help (like specifically in the case of the Clone dialog) even though it wouldn't help with dialogs containing writable inputs. (E.g. on the repository page, click Flag For Later instead and press Shift+Tab and Escape.) A better fix would lie at https://we.phorge.it/source/phorge/browse/master/webroot/rsrc/externals/javelin/lib/Workflow.js$413 where either the getSpecialKey would need improvement itself to return true for these non-modifying keys, or it would need to be amended with a custom check in that regard. However, I don't know where that function comes from.