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

Cannot save "Make template part" when the template part name is in multibyte language #38160

Closed
waviaei opened this issue Jan 23, 2022 · 3 comments · Fixed by #38695
Closed
Assignees
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@waviaei
Copy link
Contributor

waviaei commented Jan 23, 2022

Description

In the new (theme) editor, one can save block(s) as template parts, accessed via the "three-dots" menu. It seems you cannot save it if multibyte language is used as template part name.

Looking at the console error, there seem to be something with creating slug from the input text? and JS has stopped there, resulting in "saving" to not finish.

I tried same thing with English template name, and it worked.

Note: I have not tested in other multibyte language such as CK, but looking at the nature of the issue, I am suspecting it is multi-byte related.

Step-by-step reproduction instructions

  1. Pick something and click the three-dots menu (Here, I made a tweak at Query Loop for Home template)
  2. Click "Make template part"
  3. Enter multibyte language e.g. 私のテンプレートパーツのテスト
  4. Click "Create"

You should see that Create button do the animation to save, but never seem to end. If you keep open the dev tool console tab, you should be able to see `Cannot read properties of undefined (reading 'slug) error.

スクリーンショット 2022-01-23 17 30 52

(here you seeing the error three times, because I attempted three times)

Repeat above with non-multibyte language and you won't encounter the error.

Screenshots, screen recording, code snippet

No response

Environment info

  • WordPress 5.9-RC3-52619 (using beta plugin)
  • Theme: I checked with Automattic's Blockbase (v 2.0.15) and Livro (1.0.1) from .org. I could not activate twentytwenty two, as I got "It is not compatible with this version of WordPress, please update".

Gutenberg is deactivated.

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@Mamaduka Mamaduka added [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Type] Bug An existing feature does not function as intended labels Jan 23, 2022
@Mamaduka Mamaduka added this to 📥 To do in WordPress 5.9.x via automation Jan 26, 2022
@Mamaduka
Copy link
Member

Here's the error from the REST API response:

{"code":"rest_invalid_param","message":"Invalid parameter(s): slug","data":{"status":400,"params":{"slug":"slug does not match pattern [a-zA-Z0-9_\\-]+."},"details":{"slug":{"code":"rest_invalid_pattern","message":"slug does not match pattern [a-zA-Z0-9_\\-]+.","data":null}}}}

I also noticed that I could create Templates using multibyte string as a name, but then I'm getting the following error if I try to delete it.

{"code":"rest_no_route","message":"No route was found matching the URL and request method.","data":{"status":404}}
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Feb 10, 2022
WordPress 5.9.x automation moved this from 📥 To do to ✅ Done Feb 11, 2022
@inc2734
Copy link
Contributor

inc2734 commented Feb 15, 2022

If insert a template part block and try to create a new template part block with multibyte characters, an error will occur.

スクリーンショット 2022-02-15 23 38 14

Gutenberg version: 12.7.20220214

@Mamaduka
Copy link
Member

Thanks for contributing, @inc2734.

I thought I covered all cases. I will have a look tomorrow and create a follow-up PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
3 participants