- Issue created by @gapple
- ๐จ๐ฆCanada gapple
Created a quick MR to update the element types that have
disabled
property set. - Status changed to Needs review
almost 2 years ago 12:15am 19 April 2023 - last update
almost 2 years ago 29,283 pass - @gapple opened merge request.
- Status changed to Needs work
almost 2 years ago 1:38pm 19 April 2023 - ๐บ๐ธUnited States smustgrave
Definitely needs tests.
May even be worth a change record so others know they can disable those elements.
- ๐บ๐ธUnited States dww
For the tests this needs, see:
core/tests/Drupal/FunctionalJavascriptTests/Core/Form/JavascriptStatesTest.php
core/modules/system/tests/modules/form_test/src/Form/JavascriptStatesForm.phpFeel free to ask me (here or Slack) if anyone needs help figuring out how to extend that test.
Thanks!
-Derek - First commit to issue fork.
- last update
almost 2 years ago Custom Commands Failed - last update
almost 2 years ago 29,304 pass - ๐บ๐ฆUkraine yevhenlebid51
Thanks for the patch, everything works.
But it didn't apply to the core/misc/states.js file, I downloaded the patch and changed the path manually to the core/misc/states.es6.js - ๐ฆ๐นAustria daniel.pernold
Same problem here with Drupal 9.5.9. Patch #10 solved the problem.
- Status changed to RTBC
over 1 year ago 5:09pm 23 July 2023 - last update
over 1 year ago Custom Commands Failed - last update
over 1 year ago Custom Commands Failed - Status changed to Needs work
over 1 year ago 6:38pm 23 July 2023 - ๐ฌ๐งUnited Kingdom longwave UK
Needs reroll for 11.x first before we can consider backporting. Also as stated in #2 and #5 this could do with additional test coverage.
- last update
over 1 year ago 29,877 pass - ๐ฎ๐ณIndia devsoni Ahmedabad
Thank you for the patch it seems working for drupal 10.1.x but as per project requirements I have added one more element "submit" in patch file.
- ๐จ๐ฆCanada gapple
๐ง
<submit>
isn't a valid HTML element?https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled
- ๐ฎ๐ณIndia aadeshvermaster@gmail.com
hi @devsoni,
I applied your patch #20 in our project where drupal version is 9.5.10 and its working fine too.
Thanks
- ๐ฆ๐บAustralia sonnykt Melbourne, Australia
Patch #20 cannot be applied to Drupal 10.1.5.
Patch #16 can be applied and fixes the issue.
- ๐ฆ๐บAustralia Seth Hilder
This patch is an updated version of #16 that also fixed an issue where e.value was undefined when the #states rules are no longer being met, and you are trying to make things enabled. This undefined-ness was leading to different behavior between toggleClass() and prop(), which was preventing the disabled prop not being set when it should have been, even though the form-disabled class was being set.
This very much feels like fixing the symptom and not the cause, but the cause is seemingly buried in the verifyConstraints/checkConstraints code which I unfortunately don't have time to dig into.
- ๐ช๐ธSpain penyaskito Seville ๐, Spain ๐ช๐ธ, UTC+2 ๐ช๐บ
#23 didn't work for action submit element, but the MR did.
- ๐ฉ๐ชGermany a.dmitriiev
#16 works for me, #23 doesn't work with checkboxes (at least)
- First commit to issue fork.
- Merge request !5694Convert patch 3354998-16.patch into a merge request and add test coverage. โ (Closed) created by phthlaap
- ๐ป๐ณVietnam phthlaap
I've created a merge request for version 11.x and added test coverage.
- Status changed to Needs review
about 1 year ago 4:13pm 5 December 2023 - ๐ป๐ณVietnam phthlaap
phthlaap โ changed the visibility of the branch 3354998-states-disable-elements to hidden.
- Status changed to Needs work
about 1 year ago 2:35pm 6 December 2023 - ๐บ๐ธUnited States smustgrave
Could it be documented what element types were discovered not working, IS mentions button but MR has other elements it's testing.
- ๐บ๐ธUnited States robphillips
Adding D10.1 compatible patch based on latest MR.
- Status changed to Needs review
about 1 year ago 6:27am 7 December 2023 - ๐ป๐ณVietnam phthlaap
This issue happen with submit button
$form['actions']['submit'] = [ '#type' => 'submit', '#value' => $this->t('Submit'), '#states' => [ 'disabled' => [':input[name="allow_overwrite"]' => ['checked' => FALSE]], ], ];
- Status changed to Needs work
about 1 year ago 4:02pm 7 December 2023 - ๐บ๐ธUnited States smustgrave
Issue summary and title should be updated to reflect that.
The issue summary and solution should line up.
Add additional HTML elements to the
find()
parameter.What additional elements were added?
- Status changed to Needs review
11 months ago 9:55pm 8 March 2024 - ๐จ๐ฆCanada Liam Morland Ontario, CA ๐จ๐ฆ
Updated issue summary. I am having this problem for submit buttons.
- Status changed to Needs work
11 months ago 2:59pm 15 March 2024 - ๐บ๐ธUnited States smustgrave
Tests appear to be added so removing that tag
D9 is done so removing the backport tag.
Looking at the MR though it doesn't match what's proposed in the summary. Can the MR or summary be updated please
Left a small nitpicky but moving to NW for the summary.
- ๐จ๐ฆCanada Liam Morland Ontario, CA ๐จ๐ฆ
I have updated the merge request so that
.find()
includes all elements that support thedisabled
attribute. This means that the attributes added match what the summary says need to be added.I note that the summary does not mention adding the call to
.addBack()
. Perhaps @phthlaap can add documentation about that. - ๐จ๐ฆCanada Liam Morland Ontario, CA ๐จ๐ฆ
select
,textarea
,input
are already in the.find()
. That list is just the ones being added. - Status changed to Needs review
11 months ago 9:28pm 15 March 2024 - Status changed to Needs work
11 months ago 10:07pm 15 March 2024 The Needs Review Queue Bot โ tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide โ to find step-by-step guides for working with issues.
- ๐จ๐ฆCanada Liam Morland Ontario, CA ๐จ๐ฆ
I looked in more detail at the history.
.addBack()
was in the patch in comment 8 by @jedihe and may be been there when the merge request was first opened in comment 3 by @gapple. - Status changed to Needs review
10 months ago 5:09pm 18 March 2024 - ๐ป๐ณVietnam phthlaap
Tested without
addBack(tagsSupportDisable)
, the issue wasn't fixed. This change has been applied since patch #31. - ๐จ๐ฆCanada gapple
I haven't checked the latest code in the merge request, but if IIRC, the
addBack()
was necessary because while in most cases the affected element has a wrapper with one of the relevant.js-form-item, .js-form-submit, .js-form-wrapper
classes and thefind()
call will return the proper child node, there are some cases where the class is applied to the element itself.
Whileclosest()
will return the element it is called on if it matches the selector,find()
does not.addBack()
will append the element that was returned byclosest()
if it matches the list of element types.
Only one offind()
oraddBack()
should return an element.It should have the same result as this, without needing a variable or conditional block:
elem = eventTarget.closest(wrapperClasses); if (!elem.is(tagsSupportDisable)) { elem = elem.find(tagsSupportDisable) }
- ๐จ๐ฆCanada gapple
@jedihe was the one who added the
addBack()
in #7 / #8https://git.drupalcode.org/project/drupal/-/merge_requests/3844/diffs?co...
- Status changed to RTBC
10 months ago 1:46pm 21 March 2024 - ๐บ๐ธUnited States smustgrave
Hiding patches for clarity
Ran test-only feature
1) Drupal\FunctionalJavascriptTests\Core\Form\JavascriptStatesTest::testJavascriptStates Failed asserting that false is true. /builds/issue/drupal-3354998/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php:121 /builds/issue/drupal-3354998/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php:55 /builds/issue/drupal-3354998/core/tests/Drupal/FunctionalJavascriptTests/Core/Form/JavascriptStatesTest.php:509 /builds/issue/drupal-3354998/core/tests/Drupal/FunctionalJavascriptTests/Core/Form/JavascriptStatesTest.php:74 /builds/issue/drupal-3354998/vendor/phpunit/phpunit/src/Framework/TestResult.php:728 FAILURES! Tests: 1, Assertions: 213, Failures: 1.
Which shows test coverage
Issue summary appears to have been updated so removing that tag.
Thanks everyone for the digging into the addBack. Seems fine to me now
- Status changed to Fixed
10 months ago 2:05pm 24 March 2024 Automatically closed - issue fixed for 2 weeks with no activity.
- ๐บ๐ธUnited States darren oh Lakeland, Florida
Darren Oh โ made their first commit to this issueโs fork.