- 🇺🇸United States smustgrave
This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request → as a guide.
This will need a test case to show the issue
Did not test patch yet.
- 🇧🇷Brazil joaopauloc.dev
Adding unit test for field links using states
Patch #19 didn't work with me, it was necessary to do a small fix in state.js, see changes interdiff file - 🇺🇸United States smustgrave
Tested on Drupal 10.1.x with a standard install.
Picked a random module with a form, in this case admin_toolbar, and added$form['checkbox'] = [ '#type' => 'checkbox', '#title' => t('Show link'), ]; $form['link'] = [ '#type' => 'link', '#title' => t('Link to front page'), '#url' => Url::fromRoute('<front>'), '#states' => [ 'visible' => [ ':input[data-drupal-selector=edit-checkbox]' => ['checked' => TRUE], ], ], ];
Verified the data-drupal-selector wasn't there and the link was appearing.
Applied the fix and the attribute was there and the link was hidden until I checked the box.Good job with the tests!
- 🇬🇧United Kingdom longwave UK
-
+++ b/core/misc/states.js @@ -714,9 +714,15 @@ + // Check if target is a link. + if (e.target.tagName === 'A') {
This feels a bit too hardcoded, and the comment doesn't explain *why* we are doing this. Maybe we should add
.js-form-item
to the link itself when#states
is used, then I think we could leave the JavaScript alone? -
+++ b/core/tests/Drupal/FunctionalJavascriptTests/Core/Form/JavascriptStatesTest.php @@ -103,11 +104,13 @@ protected function doCheckboxTriggerTests() { + $this->assertFalse($link->isVisible());
In 🐛 #states cannot check/uncheck checkboxes elements Fixed we added a third round of tests in this method to ensure the state was correctly reset after unchecking the checkbox again; we should add the same check for this change.
-
- 🇺🇦Ukraine myha
I made that work for 9.5 by add 'container' element and put states here. Link added inside 'container'.
- 🇧🇷Brazil joaopauloc.dev
Hello @longwave,
I added the third round validating the checkbox. Also, I updated the commend on state.js explaining better why we update the element.I agree with you that's is too hard-coded. But at the same time, in this case, should be hard coded, because we need to check if the element is a link tag. What do you think if we keep it as it is but explain why we are doing this?
About your suggestions I think is a good idea, maybe we should have a new js class to state.js handle these cases instead of checking the element tag, in the future, we could have more elements using this feature by just adding this class. My only concern about this idea is the link state won't work out of the box, we should add a new class to the link form element. I guess that we can't use the already existing class(js-form-item, .js-form-submit, .js-form-wrapper) because the links are not wrapped by them.
Regards.
- Open on Drupal.org →Environment: PHP 8.2 & MySQL 8last update
over 1 year ago Waiting for branch to pass - @joaopaulocdev opened merge request.
- last update
over 1 year ago 29,330 pass, 17 fail - Open on Drupal.org →Environment: PHP 8.2 & MySQL 8last update
over 1 year ago Waiting for branch to pass - @joaopaulocdev opened merge request.
- Open on Drupal.org →Environment: PHP 8.2 & MySQL 8last update
over 1 year ago Waiting for branch to pass - @joaopaulocdev opened merge request.
15:03 14:26 Running- Status changed to Needs review
over 1 year ago 12:35pm 10 May 2023 - Status changed to RTBC
over 1 year ago 9:06pm 12 May 2023 - 🇺🇸United States smustgrave
Seems the points brought up in #29 have been addressed.
- last update
over 1 year ago 29,388 pass - Open on Drupal.org →Environment: PHP 8.1 & MySQL 5.7last update
over 1 year ago Waiting for branch to pass - last update
over 1 year ago 29,388 pass - last update
over 1 year ago 29,388 pass - last update
over 1 year ago 29,388 pass - Open on Drupal.org →Environment: PHP 8.1 & MySQL 5.7last update
over 1 year ago Waiting for branch to pass 55:49 50:03 Running- last update
over 1 year ago 29,399 pass - last update
over 1 year ago 29,399 pass - last update
over 1 year ago 29,400 pass - last update
over 1 year ago 29,409 pass - last update
over 1 year ago 29,409 pass 40:48 37:23 Running- last update
over 1 year ago 29,420 pass - last update
over 1 year ago 29,420 pass - last update
over 1 year ago 29,425 pass - last update
over 1 year ago 29,429 pass - last update
over 1 year ago 29,430 pass - last update
over 1 year ago 29,430 pass - last update
over 1 year ago 29,430 pass - Status changed to Needs work
over 1 year ago 10:30pm 22 June 2023 - 🇬🇧United Kingdom longwave UK
The comment for the A tag case needs rewording, but I'm not sure what to suggest.
- last update
over 1 year ago Custom Commands Failed - last update
over 1 year ago 29,436 pass - Status changed to Needs review
over 1 year ago 3:07pm 23 June 2023 - Status changed to RTBC
over 1 year ago 6:47pm 23 June 2023 - 🇺🇸United States smustgrave
Change makes sense.
If the committer get to it first need to remove duplicate // from the states.js, but didn't think it was enough to hold up.
@joaopauloc.dev if you see this before the committer mind removing that please.
Thanks
- last update
over 1 year ago 29,436 pass - last update
over 1 year ago 29,436 pass - last update
over 1 year ago 29,436 pass - last update
over 1 year ago 29,441 pass - last update
over 1 year ago 29,444 pass - last update
over 1 year ago 29,443 pass - last update
over 1 year ago 29,443 pass 25:48 24:34 Running- last update
over 1 year ago 29,439 pass - last update
over 1 year ago 29,441 pass - last update
over 1 year ago 29,444 pass - last update
over 1 year ago 29,444 pass 40:48 39:39 Running- last update
over 1 year ago 29,446 pass - last update
over 1 year ago 29,446 pass - last update
over 1 year ago 29,446 pass - last update
over 1 year ago 29,451 pass - last update
over 1 year ago 29,453 pass - last update
over 1 year ago 29,454 pass - Status changed to Needs review
over 1 year ago 9:55am 29 July 2023 - Status changed to RTBC
over 1 year ago 4:20pm 5 August 2023 - last update
over 1 year ago 29,458 pass - last update
over 1 year ago 29,459 pass - last update
over 1 year ago 29,459 pass - last update
over 1 year ago 29,465 pass - last update
over 1 year ago 29,465 pass - last update
over 1 year ago 29,465 pass - last update
over 1 year ago 29,465 pass - last update
over 1 year ago 29,469 pass - last update
over 1 year ago 29,469 pass - last update
over 1 year ago 29,469 pass - last update
over 1 year ago 29,469 pass - Status changed to Needs work
over 1 year ago 4:25am 25 August 2023 - 🇳🇿New Zealand quietone
I'm triaging RTBC issues → .
After reading the issue summary I wonderws if drupal_process_states, mentioned in the proposed resolution, was still in use. So, I searched and found and found that it was deprecated in 2019, #3000068: Deprecate drupal_process_states() → . I am tagging for an issue summary update.
Reading the comments, I see that @lauriii has asked for a less risky solution. I think that warrants setting this back for work.
I am setting back to NW.
- last update
over 1 year ago 30,134 pass, 1 fail - @joaopaulocdev opened merge request.
- last update
over 1 year ago 30,136 pass - Status changed to Needs review
over 1 year ago 9:41pm 4 September 2023 - 🇧🇷Brazil joaopauloc.dev
- New mr created from 11.x
- Added support to js/state for links in Link element as @lauriii suggested
- Status changed to RTBC
over 1 year ago 4:12pm 5 September 2023 - 🇺🇸United States smustgrave
Removing summary update tag as that was done in #49
- last update
over 1 year ago 30,136 pass - last update
over 1 year ago 30,134 pass, 2 fail - last update
over 1 year ago 30,146 pass - last update
over 1 year ago 30,150 pass - last update
over 1 year ago 30,154 pass 10:48 8:26 Running- last update
over 1 year ago 30,168 pass - last update
over 1 year ago 30,168 pass - last update
about 1 year ago 30,205 pass - last update
about 1 year ago 30,206 pass - last update
about 1 year ago 30,360 pass - Status changed to Needs work
about 1 year ago 8:47am 28 September 2023 - 🇫🇮Finland lauriii Finland
Nice! The current approach looks less scary. I posted few comments on the MR but I think we're getting there
- last update
about 1 year ago Build Successful - Status changed to Needs review
about 1 year ago 4:55pm 28 September 2023 - last update
about 1 year ago Build Successful - 🇺🇸United States smustgrave
Seemed to have some test failures so rerunning
- last update
about 1 year ago Build Successful - last update
about 1 year ago Build Successful - Status changed to Needs work
about 1 year ago 8:04pm 29 September 2023 - 🇺🇸United States smustgrave
Have reran the tests a few times but seems something is breaking.
- last update
about 1 year ago Custom Commands Failed - last update
about 1 year ago 30,348 pass, 2 fail - last update
about 1 year ago 30,360 pass - Status changed to Needs review
about 1 year ago 10:15pm 30 September 2023 - Status changed to RTBC
about 1 year ago 6:14pm 2 October 2023 - 🇺🇸United States smustgrave
Didn't see a test-only patch and the test-changes feature of gitlab is blocking me.
So ran locally without the changes to core/misc/states.js core/lib/Drupal/Core/Render/Element/Link.php
There was 1 failure: 1) Drupal\FunctionalJavascriptTests\Core\Form\JavascriptStatesTest::testJavascriptStates Failed asserting that true is false. /var/www/html/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php:122 /var/www/html/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php:55 /var/www/html/web/core/tests/Drupal/FunctionalJavascriptTests/Core/Form/JavascriptStatesTest.php:226 /var/www/html/web/core/tests/Drupal/FunctionalJavascriptTests/Core/Form/JavascriptStatesTest.php:65 /var/www/html/vendor/phpunit/phpunit/src/Framework/TestResult.php:728
Great!
So reviewing the change itself, shame we need specialty code for links in the states.js but confirmed it does work using the example in the IS.
All threads appear to be resolved.
Great work!
- last update
about 1 year ago 30,362 pass - last update
about 1 year ago 30,379 pass - last update
about 1 year ago 30,377 pass - Status changed to Needs work
about 1 year ago 3:07pm 7 October 2023 - last update
about 1 year ago 30,382 pass - last update
about 1 year ago 30,382 pass - Status changed to Needs review
about 1 year ago 6:37pm 7 October 2023 - Status changed to RTBC
about 1 year ago 8:07pm 9 October 2023 - 🇺🇸United States smustgrave
Seems threads have been resolved.
Tested again following the IS.
Took that code snippet and added to the Performance Form.
States did not work, as both elements rendered.
Applied the MR and states work perfectly. - last update
about 1 year ago 30,384 pass - Status changed to Fixed
about 1 year ago 7:47am 11 October 2023 Automatically closed - issue fixed for 2 weeks with no activity.