gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Commas inserted into values with '>' attribute selector

Open morganisok opened this issue 8 years ago • 2 comments

Issue Overview

When you declare custom block attributes, if you include '>' in the selector, commas get inserted between every character of the value.

Steps to Reproduce (for bugs)

  1. Create a custom block, with '>' in the selector, such as: email: { type: 'array', source: 'attribute', selector: '.email > a', attribute: 'mailto' }, for a complete code example, see https://gist.github.com/wpalchemist/2bf2fee33d5d31c43c61cf053c9d2f78
  2. Create a post with that block and save it. The first time you save, it will be fine.
  3. Edit the post, and save it again - now commas will be inserted between every character of that attribute
  4. Every time you save the post, more commas will be inserted

Expected Behavior

Data should be saved exactly as it is entered.

Current Behavior

Commas are inserted between every character every time the data is saved.

Removing '>' fixes the problem, but there are situations where developers will need it there.

Possible Solution

Screenshots / Video

Related Issues and/or PRs

Todos

  • [ ] Tests
  • [ ] Documentation

morganisok avatar Dec 09 '17 01:12 morganisok

I suspect you're having the issue because you're using "Editable" for your different inputs (The value of the Editable is not a simple a string, it's an array). "Editable" is only meant to be used for "formatted" text. For email, phones and stuff like that, it might be better to just use simple inputs or textareas

youknowriad avatar Dec 10 '17 11:12 youknowriad

I'm closing this. Please feel free to reopen if my comment above doesn't address your issue.

youknowriad avatar Dec 26 '17 10:12 youknowriad