Skip to content

Commit

Permalink
Speed up and slow down typing so ajax comboboxes have time to react
Browse files Browse the repository at this point in the history
  • Loading branch information
plocket committed Feb 23, 2024
1 parent 946be2d commit 7eef875
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Format:

- Handle non-existence of `elem` more robustly when checking for `elem.disabled`
- Add a pause between pull request tests and push tests when the PR is coming from our own repo
- Make getting page field values more robust by doing more to ensure that undefined values don't cause errors
- Make getting page field values more robust by doing more to ensure that undefined option `value`s don't cause errors. For example, ajax combobox `select` options don't always have `value`s

## [5.9.0] - 2024-02-11

Expand Down
13 changes: 9 additions & 4 deletions lib/scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -1976,11 +1976,16 @@ module.exports = {

setText: async function ( scope, { handle, answer }) {
// Set text in some kind of field (input text, input date, textarea, etc.)
await handle.evaluate( el => { el.value = '' });
// First set the value to part of the string
const to_set = answer.slice(0, -3);
const to_type = answer.slice(-3);
await handle.evaluate(( elem, text ) => {
elem.value = text;
}, to_set );
// Then type the last three characters of the string with a
// good pause to let the field register the interaction
await handle.focus();
let delay = 0;
if ( session_vars.get_debug() ) { delay = 25; }
await handle.type( answer, { delay });
await handle.type( to_type, { delay: 100 });
},

draw_signature: async function ( scope, name ) {
Expand Down

0 comments on commit 7eef875

Please sign in to comment.