MDL-70148 behat: Use key_press for autocomplete escape

In Moodle 3.5 dialogues are focused too frequently and active focus is
often wrong. This means that the dialogue has focus after selecting an
element in a form autocomplete element. As a result, pressing the escape
key causes the dialogue to be closed.

The older `key_press` call is sufficient to close the autocomplete in
the cases where this is needed, but will not cuase the dialogue to be
closed.
This commit is contained in:
Andrew Nicols
2020-11-20 09:03:09 +08:00
parent 938d0763f6
commit e32b77b7a3
@@ -82,8 +82,9 @@ class behat_form_autocomplete extends behat_form_text {
}
$this->wait_for_pending_js();
// Press the escape to close the autocomplete suggestions list.
behat_base::type_keys($this->session, [behat_keys::ESCAPE]);
// Note: This does not make use of the `type_keys` API because it can cause some modals to close.
// This is not an issue in later versions of Moodle where the autocomplete handling has been updated.
$this->key_press(27);
$this->wait_for_pending_js();
}
}