Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minify field HTML is too aggressive #6390

Closed
mynetx opened this issue Jul 28, 2022 · 3 comments · Fixed by #6394
Closed

Minify field HTML is too aggressive #6390

mynetx opened this issue Jul 28, 2022 · 3 comments · Fixed by #6394

Comments

@mynetx
Copy link
Contributor

mynetx commented Jul 28, 2022

Bug description

We’re using HTML inside a checkbox option value. Spaces after tags are removed. This causes words to stick together.

Rendered:

<label for="accept_privacy[]-62e2482cd8cea" class="text-base text-current leading-tight text-left select-none">Ich akzeptiere die <a href='/datenschutz' class='underline hover:no-underline'>Datenschutzbestimmungen</a>und bin mit der Verarbeitung meiner Daten gemäß DSGVO einverstanden.

Note the missing space between “Datenschutzbestimmungen” and “und”.

The problem is caused by the regex in RendersForms::minifyFieldHtml(), introduced in #4949 (9ba5e2d).

How to reproduce

Prepare a form with a checkbox:

      -
        handle: accept_privacy
        field:
          inline: false
          options:
            'yes': 'Ich akzeptiere die <a href=''/datenschutz'' class=''underline hover:no-underline''>Datenschutzbestimmungen</a> und bin mit der Verarbeitung meiner Daten gemäß DSGVO einverstanden.'
          display: Datenschutzbestimmungen
          type: checkboxes
          icon: checkboxes
          listable: hidden
          instructions_position: above
          validate:
            - required

Render the form and see the minified result (see above).

Logs

No response

Environment

Statamic 3.3.24 Pro
Laravel 8.83.23
PHP 8.0.21
webographen/statamic-dynamic-token 1.0.0
withcandour/aardvark-seo 2.0.28

Installation

Fresh statamic/statamic site via CLI

Antlers Parser

No response

Additional details

No response

@jesseleite
Copy link
Member

This PR adds a space between checkbox input and checkbox/radio label text though, which was intentionally minified to allow the user to control that gap via margin CSS. For example:

<label><input type="checkbox"> Option with <a href='/link'>a link</a> to click</label>

Thinking it should be:

<label><input type="checkbox">Option with <a href='/link'>a link</a> to click</label>

@mynetx
Copy link
Contributor Author

mynetx commented Jul 28, 2022

@jesseleite How should the regex know about this space, though? Would this not be a matter of updating the default checkboxes field Antlers template?

@jesseleite
Copy link
Member

jesseleite commented Jul 28, 2022

No we shouldn't have to modify the templating. See #6394, which addresses both of our concerns. Thank you again for taking the time to PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants