Overview
Given the following prop...
expanded:
type: boolean
title: Expand by default
description: Note that all accordions are expanded by default in the Experience Builder editor.
default: false
default_value: false
examples: [false]
none of default, default_value, nor examples seem to work for setting a default unchecked state for a boolean prop.
This may be user-error, but even if it is, it was fairly unclear how to accomplish this. I didn't find anything in https://www.drupal.org/docs/develop/theming-drupal/using-single-director... related to what examples are, and https://www.drupal.org/docs/develop/theming-drupal/using-single-director... indicates that default can be used for this purpose?
Proposed resolution
Make default values work with a mechanism, or educate and document the mechanism in a more prominent place.
User interface changes
None
| Comment | File | Size | Author |
|---|---|---|---|
| #46 | xb-multi-boolean.mp4 | 91.6 KB | heyyo |
| #12 | Screenshot 2025-05-16 at 11.01.33 AM.png | 549.29 KB | mayur-sose |
Issue fork experience_builder-3492368
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
wim leers🧐 Fixed the title! 😄
XB uses the first example value as the default. You should be able to see this at
/admin/config/development/configuration/single/export: export theComponentconfig entity for this SDC and you'll explicitly see thedefault_valuein there.Relevant docs: https://git.drupalcode.org/project/experience_builder/-/blob/0.x/docs/co... — but that does NOT state that that is used as the default value. A slight tweak to that simple bullet would go a long way I think :)
This means the test coverage in
ui/tests/e2e/prop-types.cy.jsis incomplete:— Any chance you could add the missing test coverage? 🙏
Comment #3
wim leersActually, I think this is clearer still.
Comment #5
luke.leberAll signs point to probably not 😭. NW and slowly backs away.
Comment #6
wim leersAlso, SDC allows
default: …because it's part of JSON Schema itself, but the SDC subsystem doesn't actually use/support it. I observed this 4 months ago at #3462705-19: [META] Missing features in SDC needed for XB.IOW: you're running into one of many SDC bugs/oversights we've spotted while working on XB, see #3462705: [META] Missing features in SDC needed for XB for the overview :)
Comment #7
kristen polI thought I already reported this a long time ago… hmm… maybe it was closed
Comment #8
kristen pol#3472179: [PP-1] Can't toggle boolean prop back to true after changing to false was marked as duplicate but never got fixed it seems
Well… I guess you can toggle it so not quite same thing but :shrug:
Comment #9
wim leersComment #10
kristen polThanks for bumping priority :) I find that I’ll set to false and the component behavior seems fine but the UI later shows it as true even though the component still seems to behave as it’s false … maybe that’s what’s explained in the issue summary but I’m on my phone on my flight to Atlanta so hard to read well :D
Comment #11
wim leersComment #12
mayur-sose commentedI am able to reproduce the reported bug by following the steps mentioned.
Steps to Reproduce:
Comment #13
wim leersThanks, that definitely seems like a blocker for #3515932: Milestone 1.0.0-beta1: Enable creation of non-throwaway sites then!
Comment #14
wim leersCrediting @mayur-sose for confirming this is still relevant 😊 🙏
Comment #15
wim leersThis is showing a server-side validation error, meaning the client is sending the string
"false"instead of the booleanfalse. Seems like a pretty simple bug to fix on the client :)Comment #17
mayur-sose commentedThis issue has been fixed with : #3520706.
@wim-leers we can close this ticket.
Comment #18
lauriiiComment #19
heyyo commentedI was happy to read that the boolean SDC issue has been fixed, but it looks like it didn't.
I suppose it was marked as duplicate by mistake, thinking the issue was for code components but it is for SDC components.
Comment #20
lauriiiSorry about that. I think I got confused because it looks like #12 was tested with code components but the original issue was for SDC 😅
Comment #21
heyyo commentedI want this closed as you do, don't worry 😛
Comment #22
wim leers@mayur-sose: Why did you link to #3520706: Can't add in-browser code component with checkbox prop to the library? That's completely unrelated to the bug reported here 😅 That was about creating a
(JavaScript)Componentconfig entity, this is about using an SDC that is available as a component in XB, and then trying to use the widget in the component instance form on the right to populate that prop.Can you please test again with an SDC as described in the issue summary? 🙏 Thanks!
Comment #23
mayur-sose commented@wim-leers, I am able to reproduce this issue where default value of `false` does not work for boolean props.
Comment #24
mayur-sose commentedComment #25
effulgentsia commentedComment #26
thoward216 commentedI am able to reproduce this issue with SDCs, although I am also seeing an issue whereby if I toggle a boolean field from true to false, save the changes and then refresh the page the toggle has gone back to the true state. Looking at the data saved in the database it has saved correctly there so this looks to be a UI bug.
This can easily be seen with something like the Shoe Badge SDC and toggling the "pulse" boolean and saving the pulse effect in the preview does not happen but the toggle is showing as true.
I wonder if this is some of the root cause to the default values not working as expected here as the UI is not reflecting the correct state? Or could be something separate, if so I can create a new ticket for this.
As mentioned in #2 it does look like the default value used is the first value in the examples.
Comment #27
thoward216 commentedComment #28
thoward216 commentedComment #29
wim leersThe
phpunittest failures are trivial expectation updates.The back end is clearly returning (
/xb/api/v0/config/component) the correct value:Those 2
falses at the end are what's newly tested in that explicit prop shape example. Explicit test coverage for that seems excessive, but if others disagree, we could add it toComponentInputsFormTest.The new e2e test then reproduces the reported bug:
@thoward216 Can you fix the 2 PHPUnit test failures, and comment out the failing e2e test? Then we can merge this MR, and then hand this over the FE team 😊
Comment #30
wim leersI'd swear we recently fixed this, but I can only find #3503199: `DrupalToggle` for `boolean_checkbox` widget is always toggled "on", even when `checked` attribute is absent. I bet I'm missing something.
Comment #31
thoward216 commentedI've fixed those two PHPUnit test failures, commented out the failing e2e test for now and also added a bit to the components.md - let me know if this needs expanding.
Comment #32
wim leersYou've commented out the entire e2e test — please comment out only the bit for
test_bool_default_false🙏Comment #33
thoward216 commentedOh yes! That was a silly mistake, have fixed that now!
Comment #34
thoward216 commentedTests are now all passing on this.
Comment #37
wim leersGreat,
!454added explicit test coverage for shape matching (passing), and an e2e test (failing).The failing test was commented out, to allow it to be worked on by somebody who knows in-depth. See #29 for the rationale.
The
!1175MR I just created uncomments the commented out e2e test coverage @thoward216 wrote and now needs a (hopefully tiny) client-side change :)Comment #40
wim leersClosed #3532333: Boolean checkbox does not properly update on the UI as a duplicate of this one. Crediting the reporter and the person who spotted it as a duplicate.
Comment #42
bnjmnmI'd incorrectly expected this to be addressed by the de-radixification but it finally occurred to me - this is specifically for a boolean widget, not a checkbox element. The values are handled slightly differently so I wired that up and it should work fine now.
Comment #45
jessebaker commentedComment #46
heyyo commentedHi ,
I'm trying to test this boolean prop, it works better, but it looks like there is still an issue, specially when there are multiple boolean props in the same SDC.
Editing the value of one boolean prop, will change other boolean props too...
Video attached to show this weird bug
Comment #47
heyyo commentedComment #48
bnjmnmI'm not able to reproduce what was reported in #46 with the "All props" component from the
sdc_test_all_propsmodule. This component has multiple booleans (one default true, one default false), though not as many as the one in the provided videoThere are also and the e2e tests using the "All props" component that would have failed had the symptoms in #46 been occurring.
Although this does not appear reproducible with the components available within the experience builder module, we should give this a try with the component used in #46 to see what we can surface. Could @heyyo direct us to where we could find that component?
Comment #49
wim leersAny chance @heyyo forgot to run
npm run build? 🤞Comment #50
heyyo commentedI really think I did rebuilt the bundle, but you never know. I'll try to recheck in 2/3 hours from now.
The components I'm using are custom ones not available online, I may release the custom them based mainly on daisyUI and tailwind.
But I did reproduce the same bug with 2 different SDC.
Comment #52
wim leersWow, nice find, both of you!
@heyyo: could you please test @bnjmnm's follow-up MR? 🙏
Comment #53
heyyo commentedConfirmed, just tested last MT, working perfectly !
Modifying a boolean, doesn't affect other boolean anymore.
And exiting form, and returning doesn't set all boolean to true anymore.
So it's working great, I will be able to play with slider container with 30 props, and maybe 25 boolean :-)
Comment #54
wim leers🤣 You do you!
Thanks so much!
Comment #56
wim leers