From 947e0790ec8ba047ada6a37dc081de6ad294a00d Mon Sep 17 00:00:00 2001 From: nod_ <nod_@598310.no-reply.drupal.org> Date: Mon, 19 Jun 2023 10:37:33 +0200 Subject: [PATCH] Issue #3367420 by lauriii, smustgrave: Generate machine names even faster --- core/misc/machine-name.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/core/misc/machine-name.js b/core/misc/machine-name.js index b2be7bc48788..ac4f0a583a31 100644 --- a/core/misc/machine-name.js +++ b/core/misc/machine-name.js @@ -180,10 +180,19 @@ // changes, but only if there is no machine name yet; i.e., only upon // initial creation, not when editing. if ($target[0].value === '') { + // Listen to the 'change' and 'input' events that are fired + // immediately as the user is typing for faster response time. This is + // safe because the event handler doesn't include any slow + // asynchronous operations (e.g., network requests) that could + // accumulate. $source - .on('formUpdated.machineName', eventData, machineNameHandler) + .on( + 'change.machineName input.machineName', + eventData, + machineNameHandler, + ) // Initialize machine name preview. - .trigger('formUpdated.machineName'); + .trigger('change.machineName'); } }); }, -- GitLab