Closed (fixed)
Project:
Experience Builder
Component:
Page builder
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
23 Aug 2024 at 08:20 UTC
Updated:
7 Oct 2024 at 14:49 UTC
Jump to comment: Most recent, Most recent file

Comments
Comment #2
wim leersReproduced.
Proposal:
requiredattribute: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/requiredThat requires first ensuring that the form rendered for a
StaticPropSourceis told whether it is required or not when generating the form. Starting point (to just make every field widget required):Comment #3
wim leersDisregard #2 — we could do that, but it actually would likely lead to an inferior experience: the
requiredboolean attribute could then appear in multiple places in the widget. It is likely more robust, and simpler, to implement this purely on the client side.(Although accessibility considerations may end up pushing us in a different direction still, eventually.)
Comment #4
balintbrewsWe discussed this today with @jessebaker, this is what we think could be a good approach here:
placeholder,maxlength,sizeetc., but norequired. Am I missing that this is not missing? 😊requiredattribute as suggested in #2.requiredattributes at the right places, we need to extend the code where we update the model on form element changes —which then triggers the preview update—, and prevent the model update when there are missing required values. Assuming we have arefattached to the form, we can useHTMLFormElement::reportValidity()to check for that.@wim leers — what are your thoughts?
Comment #5
wim leers/xb-components:Having theAha, point 2 covers that.requiredattribute be generated on the server side is exactly what I proposed in #2, but which @lauriii told me you said you wouldn't need. I'm confused now 🤪😅ComponentPropsForm::buildForm()can figure that out. 👍IOW: I'm on board. 😄
Can we get started with a E2E test that fails on failing to find the
requiredHTML attribute of thetest_REQUIRED_stringprop on theall-propstest component? 🙏Comment #6
balintbrews/xb-field-form/{entity_type}/{entity}so we can access it at the one place we reach to render the form. I may have previously said that this is mostly a frontend issue, but I had to realize we still need to know what is supposed to be required. 😊Comment #7
wim leers#6.4 WFM!
Do you agree with
?
Comment #8
balintbrewsSure, that sounds like a great idea! Someone can get started on it, and once we have that, we can even move on to testing #4.5. TDD FTW! 😊
Comment #9
balintbrews@soaratul, would you mind getting started with this?
Comment #10
tedbowWon't assign to myself but I can start working on the setting the #required from the server side.
Comment #12
jessebaker commented@soaratul Test in pseudo code as discussed:
Comment #13
traviscarden commentedLeaving this assigned to @soaratul, but I'm going to try to pick up where @tedbow left off with the backend part of the work.
Comment #15
soaratul commentedI wrote all test cases suggested by @jessebaker and team based on assumption only - like we will not allow to...
I hope we would be doing all these checks and implementation from FE side once after fixing the BE issue to pass all the test cases we wrote with assumption.
I have written all test cases based on assumption only so might be possible that it may require some changes based on actual implementation.
Comment #16
wim leers#3473155: Redux Sync all single-value types in the SDC test all props form is in, which means AFAICT you can continue here, @soaratul! 😄
Comment #17
wim leersWhat's the status here, @soaratul? AFAICT you finished the test yesterday, does that mean you think that #7 is now done and we can move on to the subsequent steps outlined in #5?
Also: the MR conflicts with HEAD, so it needs a reroll.
Comment #18
soaratul commented@wim-leers Yes exactly
- #7 has been done with assumption
- We can now move to the subsequent in #5, along with what I've mentioned in #15
Also: I will be resolving the conflicts while verifying the test cases - and test cases can be verified only after completing all the task mentioned in #15 e.g. stop dragging, selecting, rearranging, deleting etc.. while editing component(empty required field value).
Comment #20
wim leersReported again: #3473782: Selecting "none" option for a required <select>s crashes the app. Crediting @bhuvaneshwar, the reporter.
#18: 👍 — then assigning to @traviscarden, who started working on this yesterday (see #13)
Comment #21
wim leersComment #22
traviscarden commentedUpdate: I'm on track with a solution, but there's an ugly merge conflict with
0.xinxb-general.cy.jsthat I'm trying to rebase away.Comment #23
traviscarden commentedI pushed some code that seems to work locally. I can't run Cypress tests right now for some reason; we'll see what happens on CI. The code probably isn't very elegant, but red => green => refactor, you know. 🙂
Comment #24
wim leersThe back-end changes LGTM — now we just need to get the E2E test to pass again 😇
Comment #25
wim leers@traviscarden won't be working for another several hours, while @soaratul is in the middle of his day! Plus, he wrote the E2E test, so is better suited to update it 🤞
Also, the next step here is #4.3's
HTMLFormElement::reportValidity(), which is purely front-end, so out of @traviscarden's wheelhouse.Comment #27
longwaveI implemented #4.3 - the app no longer gets stuck in a loop if you empty a required field - but have no idea where to start on the rest of #4 so leaving this again for now.
Comment #28
wim leersBen posted detailed feedback on the test coverage. The test coverage needs work to improve its reliability. Could you address that feedback, @soaratul? 🙏
Comment #30
bnjmnmThe e2e tests (and I assume most/all manual ones) were being performed on the header field in the hero component, which has a minimum length requirement in addition to being required.
A quick check of the logs makes this evident
That min length requirement is not important, so it was removed by me (then again by Wim when it was overwritten) and the tests are now testing an input where required is the only thing being checked against.
Comment #31
bnjmnmThe issue as reported isn't a problem.
The My Hero header prop is required and has this property set:
minLength: 2If I remove the minLength configuration, it handles the empty required field without a crash
I'm sure required fields could offer a better experience, but there's no issue with crashing - it's an entirely different set of prop requirements causing the crash. Min length will also need to be supported but it's unsure if this issue is the home for it.
______________________________
The IS also mentions enum. Required
enumfields will crash if_noneis chosen so it may be best to make that option unavailable before it reaches the front end.__________________
Based on the new info I'm not sure how much existing work can be re-used. I'll leave that to the folks who actively worked on the branch. The issue summary should be updated to this more accurate info + the intended approach to fixing it.
Comment #32
wim leersThat's what @traviscarden worked on. He did that only for required props, which is what this issue was prescribing.
I previously investigated the
_nonecase forenum: […]prop shapes (write-up at #3471511-13: `enum` data shapes: error when choosing "- None -" in `<select>`). I'll repeat the conclusion here for clarity:@bnjmnm: over at #3471511-15: `enum` data shapes: error when choosing "- None -" in `<select>` you said you had solved that already. But … then earlier yesterday, we merged #3472900: XBEndpointRenderer & processResponseAssets() do not support `ajaxPageState` ⇒ duplicate CSS/JS loading, which changed the
_nonehandling 😅 I suspect that's where there probably is a mismatch? 🤓 What is your updated assessment/recommendation compared to your comment #15 at #3471511? 🙏Comment #33
bnjmnmWhat was implemented for enum +
_nonein #3471511 is as-discussed and continues to work that way. Selecting_nonein a select does remove the field from the model. The recent refactoring still effectively does this, but instead of looking for _none to determine model-exclusion, it will exclude any value not defined by the enum, not just _none. There's e2e testing that confirms selecting _none works without issue.It's a different story with REQUIRED selects, but fortunately....
Ah! the logic in the MR of making it
$requiredserver side eliminates the_none- I did not see anything in the code specifically removing _none and forgot about all the excellent stuff form api does behind the scenes. The assessment in my earlier comment was based on HEAD and I should have switched branches instead of just looking at the MR before issuing my findings. 💀Apologies for the derail💀.+++++++++++++++++++++
So there is in fact a working fix for required enums that needs e2e tests. Probably all that is needed is confirming there's no _none option in a required select.
Comment #34
bnjmnmIn both 0.x and the MR, a required field with no other schema restraints will not crash when emptied - all the crashes we'd been running into are because there was a minLength requirement not being met.
In addition to it not crashing #31 demonstrates that a required field can be emptied and the preview will update with that empty value. Perhaps we should be doing something in real time about this, or perhaps it's OK to just prevent saving, which the already-added
requiredattributes would satisfy.Item 6 in comment #12 - "locking" the UI already has tests written for it in anticipation of its implementation but this specific functionality seems like it would be best to do in a separate issue as there's no (AFAIK) existing UI-lock functionality and there are probably some design discussions needed to determine how this locked UI would be conveyed to the user - or maybe it's simpler than I'm hunching. If it seems worth adding to this issue, lets get it in the IS
Comment #35
bnjmnmComment #36
wim leersThis suggests test coverage is missing?
But then #34 refers to item 6 in #12, suggesting that the "locking" test coverage should be removed?
(I agree that the "locking" bits should be left for a later issue, because they require design, whereas this is a purely functional fix.)
I'm sorry, but it's not clear to me yet what the next step is that you recommend 🙈
Comment #37
bnjmnmMy walls of text made it tough to navigate
#33 ends with me saying we need a test here that confirms the MR successfully filters _none out of required enums - sounds like you agree
Comment #38
bnjmnmComment #39
wim leersThanks, that helps!
I think #37 says the only thing missing here is test coverage for an optional enum/select field.
My confusion was: "but E2E tests are failing, so how can that then be the only thing still needed?
Turns out @soaratul introduced a subtle whitespace-only change that caused an even lower-level failure!
I just removed that, but it's still failing tests. So these are the genuine test bugs that @soaratul should still fix, right, @bnjmnm?
Comment #40
bnjmnmThere are already tests in 0.x for optional enum/select that include selecting none. They are in prop-type.cy.js and labeled
'Enum (select)'Beyond the whitespace failure, e2e tests are also failing because the new tests include checking for the "locked" feature suggested in #12, a feature that is not happening in this issue.
Comment #41
wim leersRiiiiiiiiiight! Thanks for clearing up all the confusion on my part! 🙏🙈
@soaratul, can you reduce what the tests test to the scope outlined in the issue summary that @bnjmnm updated? 🙏😊
Comment #42
wim leersYay! :D
Comment #43
wim leers@bnjmnm or @hooroomoo, needs approval from you :)
Comment #44
bnjmnmThe second requirement
does not have an e2e test
Comment #45
longwaveFixing attribution.
Comment #46
wim leersFor #44 and other feedback.
Comment #47
soaratul commentedComment #48
wim leersI was surprised to see @longwave remove the
reportValidity()check, but then I found @bnjmnm's comment at https://git.drupalcode.org/project/experience_builder/-/merge_requests/2... recommending that. I don't understand why though.Because I now see zero client-side changes that make the XB app respect the
requiredattribute that now is present for required SDC props' field widgets.I can still trigger a failure by emptying a required prop:

Comment #49
longwaveWill dig into this again today.
Comment #50
longwaveThe fix is trivial but the test took me a bit longer - fixed after some rubber duck debugging with @balintbrews
The fix only applies to HTMLInputElement because as far as I know, and for the purpose of this issue, we only care about
<input required>here.As far as I can see this fix will *not* work for the case where e.g.
minLengthis set on a text field and the minimum length is not met, because that requirement is not set up in HTML validation and so we still send invalid data to the server, but to me this case is out of scope to fix here and can be deferred until later.Comment #51
balintbrewsComment #52
bnjmnmRe #50
+1, that is why the issue summary specifies :
(and easy to miss in a lengthy issue like this)
Enforcing
requiredis more straightforward to implement than the other constraints, and last I checked the MR in this issue took care of that quite nicely.In #3474732: Premature prop validation can break the UI I am working on getting the additional constraints such as
minLengthenforced.Comment #53
bnjmnmThe validation would never be triggered, the condition would only be met if the target was
HTMLFormElementbut the target is never<form>so it wasn't doing anything. In an earlier version of this MR there was actual clientside validation happening - but adding theHTMLFormElementcondition effectively shut it off.I would have recommended a refactor to bring back the clientside validation, but the tests were passing and I could manually confirm required-as-only-constraint inputs were not crashing the app when empty. The specific requirements of the issue were met without having to add that.
I think clientside validation needs to happen and I have exactly this happening in #3474732, but the specific problems reported here did not require clientside validation to work.
A required-only-constraint prop should not fail - the CTA1 field has additional format requirements causing the fail. This is being addressed in #3474732.
I also think it's fine to expand this issue's scope and include clientside validation, it might make it easier to review since the
requiredenforcement would happen earlier, so it never reaches the server to deal with additional constraints like length and format.Comment #54
balintbrewsComment #56
balintbrewsComment #57
wim leers