Overview

Now that #3467959: SDC and code component props should be able to receive HTML, editable in formatted text fields+widgets is not going to happen on time for the demo, we need a way to differentiate between textarea and input so that we can provide better UX for filling in the longer pieces of texts.

Proposed resolution

User interface changes

Command icon 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

lauriii created an issue. See original summary.

wim leers’s picture

Assigned: Unassigned » lauriii
Status: Active » Needs review
Issue tags: +DX (Developer Experience)

How about

diff --git a/tests/modules/sdc_test_all_props/components/all-props/all-props.component.yml b/tests/modules/sdc_test_all_props/components/all-props/all-props.component.yml
index 1544192f..6e6e1643 100644
--- a/tests/modules/sdc_test_all_props/components/all-props/all-props.component.yml
+++ b/tests/modules/sdc_test_all_props/components/all-props/all-props.component.yml
@@ -11,10 +11,19 @@ props:
       examples:
         - true
     test_string:
-      title: 'String'
+      title: 'String — single line'
       type: string
+      # Implied pattern:
+      #pattern: '.''
       examples:
         - Hello, world!
+    test_string_multiline:
+      title: 'String — multi-line'
+      type: string
+      # @see https://json-schema.org/understanding-json-schema/reference/regular_expressions
+      pattern: '(.|\r?\n)*'
+      examples:
+        - "Hello,\nworld!"
     test_REQUIRED_string:
       title: 'String'
       type: string

And we can make that simpler of course, for those who prefer that:

    test_string_multiline_ref:
      title: 'String — multi-line ($ref)'
      type: string
      $ref: json-schema-definitions://experience_builder.module/multi-line-string
      examples:
        - "Hello,\nworld!"

or perhaps even multiple aliases, for example:

    test_string_multiline_ref:
      title: 'String — multi-line ($ref, alias)'
      type: string
      $ref: json-schema-definitions://experience_builder.module/textarea
      examples:
        - "Hello,\nworld!"
lauriii’s picture

Assigned: lauriii » Unassigned
Status: Needs review » Needs work

Something like $ref: json-schema-definitions://experience_builder.module/textarea would probably make sense 👍

wim leers’s picture

Assigned: Unassigned » lauriii
Status: Needs work » Needs review
StatusFileSize
new28.1 KB
  1. I added the new JSON schema definition: https://git.drupalcode.org/project/experience_builder/-/merge_requests/2...
  2. I updated the all-props test SDC: https://git.drupalcode.org/project/experience_builder/-/merge_requests/2...
  3. I updated \Drupal\experience_builder\SdcPropJsonSchemaType::computeStorablePropShape(): https://git.drupalcode.org/project/experience_builder/-/merge_requests/2...
  4. It shows up:

Less than 10 minutes 👍

Next step: updating \Drupal\Tests\experience_builder\Kernel\SdcPropToFieldTypePropTest to expect more results.

@lauriii, is that sample in all-props.component.yml to your liking? 😊

wim leers’s picture

Component: Page builder » Data model
Assigned: lauriii » tedbow

… and now I've actually finished implementing this completely, because:

  1. Update StringLongItemOverride to specify an additional validation constraint that conveys newlines are actually allowed, allowing it to match against json-schema-definitions://experience_builder.module/textarea … is enough to make it all work 😊

Ready for final review now 😄 @tedbow is the only other person who's been delving into this area, so assigning to him.

tedbow’s picture

Assigned: tedbow » wim leers
Status: Needs review » Needs work

Looks good. 1 suggestion to make how this works clearer

tedbow’s picture

Status: Needs work » Reviewed & tested by the community

Add my small suggestion

  • tedbow committed 02b38bbb on 0.x authored by Wim Leers
    Issue #3471171 by Wim Leers, lauriii: Allow components to use textarea...
tedbow’s picture

Status: Reviewed & tested by the community » Fixed
lauriii’s picture

Really nice to see we were able to land this issue this quickly! 🚀 Great team work @Wim Leers and @tedbow! 💯 👏

wim leers’s picture

Assigned: wim leers » Unassigned
kristen pol’s picture

Should there be a follow-up issue to add textarea schema refs to any of the existing XB components so there is an example?

wim leers’s picture

Component: Data model » Shape matching

Status: Fixed » Closed (fixed)

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