The Needs Review Queue Bot → tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide → to find step-by-step guides for working with issues.
- 🇺🇸United States brad.bulger
I have a multivalue field (a list of emails with an Add another button) with a change event ajax trigger on each item of the field (eg field_email[0][value]). The problem I am having is that if I disable refocus, and then end up having to replace the entire field, the focus ends up at the top of the form.
Would this fix cover that problem? Or maybe one of the related issues? The best thing would be if the cursor ended up where it was going to go before ajax intervened, I don't know if that's possible.
- 🇨🇦Canada mgifford Ottawa, Ontario
- Status changed to Needs review
about 1 year ago 2:43pm 11 September 2023 - last update
about 1 year ago Custom Commands Failed - last update
about 1 year ago Custom Commands Failed - last update
about 1 year ago 30,146 pass - Status changed to Needs work
about 1 year ago 4:52pm 11 September 2023 - 🇺🇸United States smustgrave
Woo all green! Moving to NW for the tests though.
- Status changed to Needs review
about 1 year ago 5:01pm 11 September 2023 - last update
about 1 year ago CI aborted - last update
about 1 year ago CI aborted - last update
about 1 year ago CI aborted - last update
about 1 year ago CI aborted - last update
about 1 year ago 30,143 pass, 1 fail - last update
about 1 year ago Custom Commands Failed The last submitted patch, 60: 2627788-60-test-only.patch, failed testing. View results →
- last update
about 1 year ago 30,149 pass - 🇺🇸United States tim.plunkett Philadelphia
-
+++ b/core/lib/Drupal/Core/Render/Element/RenderElement.php @@ -327,6 +333,16 @@ public static function preRenderAjaxForm($element) { + $text_types = ['password', 'textfield', 'number', 'tel', 'textarea']; ... + if ($element['#ajax']['event'] === 'blur' || $element['#ajax']['event'] === 'change' && in_array($element['#type'], $text_types)) {
These 5 types all have their #ajax][event type set to blur unless it's manually set to something else... Not sure if that's what this is protecting against or not.
Additionally, the mixing of || and && without parentheses makes this extremely hard to parse.
-
+++ b/core/misc/ajax.js @@ -1083,19 +1094,30 @@ + for ( + let n = elementParents.length - 1; + !target && n >= 0; + n-- + ) {
Is this how JS wants us to format
for
loops?Also, any reason to not use the more standard
i
instead ofn
for the counter?
-
- last update
about 1 year ago 30,139 pass, 2 fail - 🇫🇮Finland lauriii Finland
The last submitted patch, 64: 2627788-64.patch, failed testing. View results →
- Status changed to RTBC
about 1 year ago 4:26pm 13 September 2023 - 🇺🇸United States tim.plunkett Philadelphia
The prettier reformatting was so jarring I didn't even notice that it was existing code, lol sorry for being distracted.
The comment change and added () make that better, thanks.
- last update
about 1 year ago 30,150 pass, 2 fail The last submitted patch, 64: 2627788-64.patch, failed testing. View results →
- last update
about 1 year ago 30,143 pass, 1 fail - last update
about 1 year ago 30,151 pass - 🇫🇮Finland lauriii Finland
Looks like unrelated random fails. #65 was 🐛 [random test failure] MenuUiTest::testMenuAdministration Active and I can't see how #67 could be caused by this given that the error occurred before any AJAX events had been triggered.
- last update
about 1 year ago 30,162 pass - last update
about 1 year ago 30,162 pass - last update
about 1 year ago 30,169 pass - last update
about 1 year ago 30,169 pass - last update
about 1 year ago 30,206 pass - last update
about 1 year ago 30,364 pass - last update
about 1 year ago 30,366 pass - last update
about 1 year ago 30,361 pass - last update
about 1 year ago 30,362 pass - last update
about 1 year ago 30,380 pass - last update
about 1 year ago 30,378 pass - last update
about 1 year ago 30,383 pass - last update
about 1 year ago Build Successful - last update
about 1 year ago 30,395 pass - Status changed to Needs work
about 1 year ago 8:56am 12 October 2023 - 🇬🇧United Kingdom alexpott 🇪🇺🌍
I think we need a change record for the new
refocus-previous
setting. Plus the issue summary needs updating for the current solution. - Status changed to RTBC
about 1 year ago 7:02pm 12 October 2023 - Status changed to Needs work
about 1 year ago 8:31am 13 October 2023 - 🇬🇧United Kingdom alexpott 🇪🇺🌍
+++ b/core/lib/Drupal/Core/Render/Element/RenderElement.php @@ -273,6 +273,12 @@ public static function preRenderAjaxForm($element) { + // Add a data attribute to attempt to focus element that was focused before + // executing ajax commands. + if ($element['#ajax']['refocus-previous'] ?? FALSE) { + $element['#attributes']['data-refocus-previous'] = "true"; + }
Discussed the meaning of "previous" with @lauriii and we decided that it is really hard to know what it means in this context. So we're going to rename it and improve the documentation.
- 🇬🇧United Kingdom alexpott 🇪🇺🌍
Also we should open an issue to document advanced AJAX settings somewhere - maybe in a section following the AJAX docs in core.api.php
- Status changed to Needs review
about 1 year ago 10:09am 13 October 2023 - last update
about 1 year ago 30,392 pass, 1 fail - 🇫🇮Finland lauriii Finland
Opened follow-up for the advanced settings: 🐛 Improve ajax system documentation to include advanced settings Active .
The last submitted patch, 73: 2627788-73.patch, failed testing. View results →
- last update
about 1 year ago 30,398 pass - 🇫🇮Finland lauriii Finland
Helps if I change the attribute name in the JavaScript code too 😇
- Status changed to RTBC
about 1 year ago 5:10pm 13 October 2023 - last update
about 1 year ago 30,398 pass - Status changed to Fixed
about 1 year ago 2:38pm 16 October 2023 - 🇬🇧United Kingdom alexpott 🇪🇺🌍
Committed and pushed 27d76911e88 to 11.x and df73d39e0ec to 10.2.x. Thanks!
-
alexpott →
committed 27d76911 on 11.x
Issue #2627788 by lauriii, DuaelFr, Pancho, vsujeetkumar, _utsavsharma,...
-
alexpott →
committed 27d76911 on 11.x
-
alexpott →
committed df73d39e on 10.2.x
Issue #2627788 by lauriii, DuaelFr, Pancho, vsujeetkumar, _utsavsharma,...
-
alexpott →
committed df73d39e on 10.2.x
Automatically closed - issue fixed for 2 weeks with no activity.