Use the `all-props` component for testing form backend + frontend integration

Created on 24 July 2024, about 2 months ago
Updated 23 August 2024, 16 days ago

Overview

We need a component that allows testing form backend + frontend integration for the forms. This is a similar idea to šŸ“Œ Introduce an example set of representative SDC components; transition from "component list" to "component tree" Fixed but with the goal of simplifiying the development / styling of form elements.

Proposed resolution


Update the existing testing component sdc_test_all_props:all-props to:

  1. āœ… render all its props (and actually render at all: #15)
  2. āœ… have default values for most props
  3. āœ… have a Component config entity that is automatically installed when the sdc_test_all_props module gets installed, for all prop shapes that have a working field type+widget (see \Drupal\Tests\experience_builder\Kernel\PropShapeRepositoryTest::testStorablePropShapes(), introduced by šŸ“Œ Support complex SDC prop shapes: introduce (Storable)PropShape to compute field type storage settings Fixed ) ā€” this automatically configures all appropriate field types, storage settings and widgets (until āœØ Preview component when selecting in left sidebar Fixed lands)

User interface changes

šŸ“Œ Task
Status

Fixed

Component

Page builder

Created by

šŸ‡«šŸ‡®Finland lauriii Finland

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @lauriii
  • šŸ‡§šŸ‡ŖBelgium Wim Leers Ghent šŸ‡§šŸ‡ŖšŸ‡ŖšŸ‡ŗ

    This component already exists, for the very reasons cited here: tests/modules/sdc_test_all_props/components/all-props/all-props.component.yml.

    It's existed for \Drupal\Tests\experience_builder\Kernel\SdcPropToFieldTypePropTest, precisely for ā€” but long prior to us having the ability to generate widgets, just finding viable storage candidates.

    (It has even existed before the 0.x branch was created!)

    And I'm literally on the path towards making exactly the intent of this issue feasible: #3461499-16: Introduce new `PropShapeInput` config entity type ā†’ .

  • šŸ‡§šŸ‡ŖBelgium Wim Leers Ghent šŸ‡§šŸ‡ŖšŸ‡ŖšŸ‡ŗ
  • Status changed to Postponed: needs info about 1 month ago
  • šŸ‡§šŸ‡ŖBelgium Wim Leers Ghent šŸ‡§šŸ‡ŖšŸ‡ŖšŸ‡ŗ

    So, can you please check if anything is missing from that all-props component? If you can't find anything missing, we can mark this issue as obsolete and unpostpone the issue it is blocking.

  • Assigned to bnjmnm
  • šŸ‡«šŸ‡®Finland lauriii Finland

    Great, thank you for pointing that out!

    @bnjmnm can you confirm if this meets the requirements or if more work is needed?

  • Status changed to Needs review about 1 month ago
  • šŸ‡§šŸ‡ŖBelgium Wim Leers Ghent šŸ‡§šŸ‡ŖšŸ‡ŖšŸ‡ŗ
  • Issue was unassigned.
  • Status changed to Active about 1 month ago
  • šŸ‡ŗšŸ‡øUnited States bnjmnm Ann Arbor, MI

    If this winds up providing all the necessary fields, then there should be at least an install hook added to sdc_test_all_propsso it is available as a Page Builder component as soon as the module is installed.

    I attempted to add the "All Props" SDC as a Page Builder component and got
    ValueError: "" is not a valid backing value for enum Drupal\experience_builder\SdcPropJsonSchemaType in Drupal\experience_builder\SdcPropJsonSchemaType::from()

    If the error šŸ‘† is addressed then I can review how this renders in the edit form and recommend if anything additional is needed.

    (I also noticed sdc_test_all_props.info.ymlhas a dependency on sdc:sdc which shouldn't be needed now that it is in core)

  • Assigned to bnjmnm
  • šŸ‡ŗšŸ‡øUnited States bnjmnm Ann Arbor, MI

    Addressed "" is not a valid backing value and digging into additional errors that surfaced once that was addressed.

  • šŸ‡ŗšŸ‡øUnited States bnjmnm Ann Arbor, MI

    I'm getting an error on any props of type: integer

    InvalidArgumentException: Field test-integer is unknown. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 616 of  
                                             /Users/ben.mullins/Sites/drupal/core/lib/Drupal/Core/Entity/ContentEntityBase.php).      

    Which happens after calling getWidget() in formTemporaryRemoveThisExclamationExclamationExclamation

  • Assigned to Wim Leers
  • šŸ‡§šŸ‡ŖBelgium Wim Leers Ghent šŸ‡§šŸ‡ŖšŸ‡ŖšŸ‡ŗ

    I'll test this with šŸ“Œ Support complex SDC prop shapes: introduce (Storable)PropShape to compute field type storage settings Fixed ā€” that issue should make this one much easier to push forward šŸ¤ž

  • Issue was unassigned.
  • Status changed to Postponed about 1 month ago
  • šŸ‡§šŸ‡ŖBelgium Wim Leers Ghent šŸ‡§šŸ‡ŖšŸ‡ŖšŸ‡ŗ

    Working on it, and as of commit e83470a84c89907bcdd73898485e5a78f03a383f, you should be unblocked here, @bnjmnm. For now, it'll require you to have šŸ“Œ Support complex SDC prop shapes: introduce (Storable)PropShape to compute field type storage settings Fixed applied.

    But really, the point here is that such an "all possible shapes" component exists (which it already does) and has a working right sidebar (which will be the case after šŸ“Œ Support complex SDC prop shapes: introduce (Storable)PropShape to compute field type storage settings Fixed ).

    So: there's nothing left to be done here for now, except wait until #3461499 is done, and then revisit.

  • šŸ‡§šŸ‡ŖBelgium Wim Leers Ghent šŸ‡§šŸ‡ŖšŸ‡ŖšŸ‡ŗ

    I've been working on expanding the test coverage over at #3461499 to verify that we truly can generate all the necessary widgets for the all-props component. I've already found a number of edge cases that indicate why @bnjmnm could not possibly have gotten this to work šŸ˜…

    This is definitely hard-blocked on #3461499, and soft-blocked on #3463999 ā€” we won't quite need that to be finished too, because I can just attach a sample config entity here šŸ‘

    Stay tuned.

  • Assigned to Wim Leers
  • Status changed to Active about 1 month ago
  • šŸ‡§šŸ‡ŖBelgium Wim Leers Ghent šŸ‡§šŸ‡ŖšŸ‡ŖšŸ‡ŗ

    LOLOL an hour worth of debugging only to find out that SDC prop names may contain dashes but Twig variable names must not: https://github.com/twigphp/Twig/issues/1967 ā€” for example

        {{ test-REQUIRED-string }}
    

    is compiled by Twig to:

            // line 5
            yield $this->extensions['Drupal\Core\Template\TwigExtension']->escapeFilter($this->env, ((($context["test"] ?? null) - ($context["REQUIRED"] ?? null)) - ($context["string"] ?? null)), "html", null, true);
    

    ā€¦ which means that the DX of SDC is leaving a lot to be desired: if Twig doesn't support this, and SDC supports only Twig, then I expect SDC to not allow this either. This is so utterly absurd šŸ¤Ŗ

    Tagging to file an upstream SDC bug report.

  • Assigned to bnjmnm
  • Status changed to Needs work about 1 month ago
  • šŸ‡§šŸ‡ŖBelgium Wim Leers Ghent šŸ‡§šŸ‡ŖšŸ‡ŖšŸ‡ŗ

    Voila, @bnjmnm is now unblocked šŸ˜Š

  • Status changed to Needs review about 1 month ago
  • šŸ‡§šŸ‡ŖBelgium Wim Leers Ghent šŸ‡§šŸ‡ŖšŸ‡ŖšŸ‡ŗ

    @bnjmnm Feel free to merge when you like ā€” this is ready as far as I'm concerned.

    If you want, you can add more props to test against. But if this suffices, then I think it's ready for you to confirm that you can trigger the above (by installing sdc_test_all_props), then you and others working on the front end can test/improve field widgets using this SDC šŸ˜Š

  • Issue was unassigned.
  • Status changed to Needs work about 1 month ago
  • šŸ‡ŗšŸ‡øUnited States bnjmnm Ann Arbor, MI

    I can't add this as a Page Component, but I suspect it will be easy to address as the error specifies a line that was committed only yesterday

     Warning: Undefined array key "#markup" in Drupal\experience_builder\Controller\SdcController->preview() (line 370 of                                            
                                              /Users/ben.mullins/Sites/drupal/modules/custom/experience_builder/src/Controller/SdcController.php) #0                                                          
                                              /Users/ben.mullins/Sites/drupal/core/includes/bootstrap.inc(108):
  • Assigned to Wim Leers
  • šŸ‡§šŸ‡ŖBelgium Wim Leers Ghent šŸ‡§šŸ‡ŖšŸ‡ŖšŸ‡ŗ

    Odd. Will double-check tomorrow with a fresh install.

  • Assigned to bnjmnm
  • Status changed to Needs review about 1 month ago
  • šŸ‡§šŸ‡ŖBelgium Wim Leers Ghent šŸ‡§šŸ‡ŖšŸ‡ŖšŸ‡ŗ
    composer require drush/drush
    vendor/bin/drush si standard --account-name=root --account-pass=root --site-name=LiveDemoWhatCouldGoWrong --yes
    vendor/bin/drush pm:install experience_builder --yes
    vendor/bin/drush pm:install sdc_test_all_props --yes
    

    Followed by creating node 1, then going to /xb, results in the screenshot I posted in #17. I didn't need to change anything.

    Any chance you just checked out this branch and already had the sdc_test_all_props installed, which would've caused the optional config to not get installed, which would explain ? šŸ¤”

    (Fixed the warning in #19 though!)

  • Issue was unassigned.
  • šŸ‡ŗšŸ‡øUnited States bnjmnm Ann Arbor, MI

    Starting from scratch gets the component to install and I can see it in the XB UI and it does its job nicely

    The problem I ran into earlier (or something similar to it) seems to be happening still - the edit/add form for this SDC isn't working. This is less urgent since it installs with the module now, but here's what I'm running into when I try to edit in admin/structure/component/edit/sdc_test_all_props:

    If I try to edit the all-props component when I click submit on the form, the submission is actually blocked by JS and there are console errors: An invalid form control with name='sdc_test_all_props+all-props[<<daterange field|UUID field>>][field_type]' is not focusable. ā€‹. It was reasonably easy to conclude this is due to the date range and UUID props not having field types selected - but still required more sleuthing than I'd expect a normal user to do (I could see this being out of scope here since it is a test-only component)

    Setting the field types in the form allowed me to submit the form, but I got the error

    Error: Call to a member function massageFormValuesTemporaryRemoveThisExclamationExclamationExclamation() on null in  
                                              Drupal\experience_builder\Form\ComponentEditForm->copyFormValuesToEntity() (line 317 of                              
                                              /Users/ben.mullins/Sites/drupal/modules/custom/experience_builder/src/Form/ComponentEditForm.php).    
    

    Since this is test only and VERY helpful to have, I think it's reasonable to address the edit form issues in another issue. For the time being, I recommend adding something specific to the edit form for this component that warns about this and perhaps makes the edit fields unavailable "This test-only component is provided as-is and cannot be edited" so we don't run into contributors losing their (or our) time assuming this would work.

  • Assigned to bnjmnm
  • šŸ‡§šŸ‡ŖBelgium Wim Leers Ghent šŸ‡§šŸ‡ŖšŸ‡ŖšŸ‡ŗ

    the edit/add form for this SDC isn't working.

    +

    [ā€¦] when I click submit on the form, the submission is actually blocked by JS and there are console errors [ā€¦]

    Ahhh, now I get why you said it wasn't working šŸ˜…

    That's known. Because configuring each component's field type + widget etc in detail using a UI is non-desirable per @lauriii. That's why šŸ“Œ Support complex SDC prop shapes: introduce (Storable)PropShape to compute field type storage settings Fixed ignored that limitation, and why šŸ“Œ Auto-create/update Component config entities for all discovered SDCs that meet XB's minimum criteria Fixed is next, and why once that is done, šŸ“Œ [PP-2] Remove Component config entity's add/edit form Postponed will happen.

    TL;DR: the current ComponentEditForm only works for components whose props are simple enough, not for arbitrarily complex SDC props.

    I think it's reasonable to address the edit form issues in another issue

    Ahead of you ā€” it will disappear shortly, in šŸ“Œ [PP-2] Remove Component config entity's add/edit form Postponed šŸ˜Š

    For the time being, I recommend adding something specific to the edit form for this component that warns about this and perhaps makes the edit fields unavailable "This test-only component is provided as-is and cannot be edited" so we don't run into contributors losing their (or our) time assuming this would work.

    Good point, we should make sure people don't waste time until #3464025 lands, done:

    ā€¦ and just to make sure: other components do not get this warning:

  • Pipeline finished with Skipped
    about 1 month ago
    #248163
  • Issue was unassigned.
  • Status changed to Fixed about 1 month ago
  • šŸ‡ŗšŸ‡øUnited States bnjmnm Ann Arbor, MI

    I tried this out and it works great. If anything is missing NBD - we just add to it later - as-is this unlocks a bunch of things we've been aiming to do.

  • šŸ‡§šŸ‡ŖBelgium Wim Leers Ghent šŸ‡§šŸ‡ŖšŸ‡ŖšŸ‡ŗ

    #25++

    This makes doing šŸ“Œ Component props form: map textarea, bool, and select elements to React components Fixed simpler, see #3462310-14: Component props form: make form elements match design ā†’ ā€” and in fact, with this now in, a superset of the 5 things listed in #3462310 is now readily available šŸ‘

    See y'all in šŸ“Œ Component props form: map textarea, bool, and select elements to React components Fixed !

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024