The wrapper of the replacement pattern gets removed on using it in view footer or header.

Steps to reproduce:

  1. Create a block of user using views.
  2. Go to Headers and add textarea field.
  3. Check the box Use replacement tokens from the first row.
  4. Add HTML <button id="edit-submit" class="add-address"><a href="/user/{{ raw_arguments.uid }} >User</a></button> inside the Content
  5. Click apply

actual result

Expected result:
A button with HTML <button id="edit-submit" class="add-address"><a href="/user/{{ raw_arguments.uid }} >User</a></button>

Actual result:
<a href="/user/{{ raw_arguments.uid }} >User</a>
This is the dom which renders:
alt

The button which is the wrapper of anchor automatically gets removed. when Use replacement tokens from the first row is checked.

Comments

himanshu_sindhwani created an issue. See original summary.

daiwik.addweb’s picture

Status: Active » Needs review
StatusFileSize
new1.65 KB

@himanshu_sindhwani, Please try with my attached patch, I hope it will help you & provide the exact solution.

Thanks

himanshu_sindhwani’s picture

Status: Needs review » Needs work

Hi @roshnipateladdweb, thanks for the patch. I reviewed the patch and saw you have added a button in $adminTags, it actually solves the case partially for me. Here are my observations:
Before patch:
if I tried to add any wrapper like div or button it got removed. For e.g. <button class='testing-wrapper'><a href='/user/{{ raw_arguments.uid }}'>Click</a></button> renders as <a href='/user/{{ raw_arguments.uid }}'>Click</a> or <div class='testing-wrapper'><a href='/user/{{ raw_arguments.uid }}'>Click</a></div> renders as <a href='/user/{{ raw_arguments.uid }}'>Click</a>

After applying patch:
<button class='testing-wrapper'><a href='/user/{{ raw_arguments.uid }}'>Click</a></button> renders as <button><a href='/user/{{ raw_arguments.uid }}'>Click</a><button> and <div class='testing-wrapper'><a href='/user/{{ raw_arguments.uid }}'>Click</a></div> still renders me <a href='/user/{{ raw_arguments.uid }}'>Click</a>

So, Classes and other attributes are removed from button and div is completely removed.

himanshu_sindhwani’s picture

Title: Wrapper gets removed while adding html textfield or textarea using replacement patters » Wrapper gets removed while adding html textfield or textarea using replacement patterns
bunty badgujar’s picture

Assigned: Unassigned » bunty badgujar
bunty badgujar’s picture

StatusFileSize
new87.97 KB

Hello @himanshu_sindhwani,
I don't think patch is needed for this functionality. You can configure Text formats to achieve this.

Steps:-

  1. Go to /admin/config/content/formats
  2. Click on configure on Full HTLM.
  3. On enable filter section check "Limit allowed HTML tags and correct faulty HTML"
  4. Scroll down to "Filter settings" and add required tags as shown in image Filter tags
  5. Save configuration. You will see you required html.
bunty badgujar’s picture

Assigned: bunty badgujar » Unassigned
himanshu_sindhwani’s picture

Hi @bunty-badgujar, I have already placed this button under text format settings. Please focus on point 3 of the steps to reproduce and then see the results. I am not sure if you have tried to reproduce.

bunty badgujar’s picture

My bad i must of confused with the description and #3. You can add any attribute in "Text format" after applying patch as mentioned in #6.
Can you verify this?

himanshu_sindhwani’s picture

Status: Needs work » Needs review
StatusFileSize
new2.43 KB
new218.98 KB
new289.66 KB

Hi @bunty-badgujar, thanks for the workaround you are right we can achieve this by applying the patch and then using full HTML as format in the text editor, but it seems very confusing which tags are allowed in textarea or Unfiltered text. I see two things here:

  1. While using textarea and full HTML, I can add any tag which I want until I check the box Use replacement tokens from the first row
  2. In the Unfiltered text, we are allowed to use a certain list of tags as mentioned in the custom field.

So, therefore, I have decided to make a patch which shows all the tags that are allowed in respective scenarios.

  1. textarea
  2. textfield
jcmartinez’s picture

Version: 8.8.5 » 10.0.x-dev
Related issues: +#2657266: Global Unfiltered Text Area Handler is in fact filtered

Thank you for the work you have done on this issue.
This issue is a duplicate of https://www.drupal.org/project/drupal/issues/2657266, which was created years before. Please do a search in the issue queue before opening a new issue.
I understand that not always it's possible to find an issue and duplicates happen. In that case, try to set the relationship between issues as accurate as possible.

himanshu_sindhwani’s picture

Version: 10.0.x-dev » 8.8.x-dev

nod_’s picture

Version: 8.8.x-dev » 9.1.x-dev
Issue tags: -views +Usability

Credit from duplicate issue, patches are made against latest development branch first, so 9.1.x right now.

This change the UI quite a bit, wouldn't mind some usability review.

If we decide a list a a good thing to have I wouldn't put the list there directly but have a link to a page that lists the tags like we do for filter tips (the "About text formats" link that points to /filter/tips).

We could also add some code to the validator function and show a message if the text contains restricted markup, that way we don't add anything to the UI for the vast majority of people.

generalredneck’s picture

Damn decent of you sir. I never knew what happens to credit when an issue is marked as duplicate. Not that I thrive on credit... but it's nice to have :)

himanshu_sindhwani’s picture

Thanks for your review @nod_ , If you add a custom Text field under fields option, this description of allowed tags is already present but missing from global custom text under header/footer. I consider this is not going to be a changes in UI and instead its an inconsistency.

nod_’s picture

Ok if it is to make it consistent, I'd try to get closer to the existing sentences, something like: You may enter data from this view as per the "Available global token replacements" above. You may include the following allowed HTML tags: xxxxx (with no space before ":").

And the description could be updated too since "Add unrestricted, custom text or markup. This is similar to the custom text field." isn't accurate.

himanshu_sindhwani’s picture

Assigned: Unassigned » himanshu_sindhwani

Ok thanks. I will work on that.

himanshu_sindhwani’s picture

StatusFileSize
new2.49 KB

Updated the patch as per #18. Please review.

himanshu_sindhwani’s picture

Assigned: himanshu_sindhwani » Unassigned

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

ranjith_kumar_k_u’s picture

StatusFileSize
new187.17 KB
new137.72 KB

The last patch works fine on 9.2 dev version
Before patch
before patch

After patch
after patch

himanshu_sindhwani’s picture

Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 19: 3136107-19.patch, failed testing. View results

spokje’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new2.49 KB

Re-uploading 3136107-19.patch so it gets tested every 2 days against 9.2.x-dev.
Until now it was tested against 9.1.x-dev.

The failure of #24 seemed to be a random FunctionalJavascript fluke so setting back to RTBC per #23

lauriii’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new2.8 KB
new808 bytes

Discussed this with @AaronMcHale, @benjifisher, @ckrina, @dardoneli, @DyanneNova and @Gábor Hojtsy in the UX call last Friday #3191695: Drupal Usability Meeting 2021-01-15. The group agreed that the current terminology could use some improvements. We reviewed the proposed changes and thought that the proposed text is too limiting since it only mentions text and link. We updated that text, as well as the description text for the filtered text area to try to make difference between the two plugins more apparent.

We also reviewed the changes for the area plugin option forms. We thought that showing the list of allowed HTML elements is a nice UX improvement since it removes any guessing from which elements are allowed.

spokje’s picture

Status: Needs review » Reviewed & tested by the community

- Like the both new texts
- TestBot is green with pride.

Back to RTBC for me.

  • catch committed 21c0c45 on 9.2.x
    Issue #3136107 by himanshu_sindhwani, lauriii, Spokje, RoshniPatel....

  • catch committed 6c96d69 on 9.1.x
    Issue #3136107 by himanshu_sindhwani, lauriii, Spokje, RoshniPatel....
catch’s picture

Version: 9.2.x-dev » 9.1.x-dev
Status: Reviewed & tested by the community » Fixed

Committed da3a22d and pushed to 9.2.x. Thanks! Also cherry-picked to 9.1.x.

Status: Fixed » Closed (fixed)

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