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

V8: Creating a Macro Partial View in the backoffice with spaces in the name can't be used with a Macro. #6590

Closed
marcemarc opened this issue Oct 6, 2019 · 2 comments · Fixed by #6592

Comments

@marcemarc
Copy link
Contributor

Using Umbraco 8.1 + 8.2RC

Create a Macro Partial View via the backoffice - right click 'Partial View Macro Files' and choose new partial view macro (without macro).

This is a common scenario, where you create the 'Macro' first, but then realise you need to now create the Partial View Macro File... (whereas if you'd created the Partial View Macro File first, you'd have the option to generate the Macro at the same time... possibly the UI for this journey could be tweaked, with the 'Macros' above the 'Partial View Macro Files' it's much more likely you will create the Macro first... anyway I digress.)

When you create the Partial View Macro File you are asked to add the 'Name' the convention for this is that it appears in the Umbraco Tree as this name... but it also sets the underlying filename of the partial view on disk...

... therefore it's quite likely you are thinking 'name' and not 'file name' and you create the name with spaces...

MacroNameWithSpaces

The Macro File Name + Macro File is created on disk with the spaces:

partialcreatedwithspaces

(should at this point the spaces have been stripped in the filename? eg it's ok for filenames to have spaces but it's only going to cause problems...)

Now switch back to the Macro... and pick the Macro File you just created... it appears in the list, but the spaces have been Url Encoded into + characters:

viewname gets plusses instead of spaces

But you can pick it and save the Macro ok... however when you try to insert the macro, the associated Partial View cannot be found...

error occurred

... because it's looking for a file on disk with plusses in!!

Anyway so there are three different places where this 'could be fixed'...

  1. filename not having spaces
  2. spaces not being url encoded as plusses when the partial is picked
    or
  3. turning the encoded plusses back into spaces when looking for the file...

So depends on if we feel we need to support having Macro Partial File Names with spaces?

@stevemegson
Copy link
Contributor

It looks like option 2 was the intended solution. The filenames are being URL encoded in C# when populating the options for the picker, and decoded in javascript when an option is picked. But javascript's decoding doesn't decode + to space. PR #6592 fixes that.

@nul800sebastiaan
Copy link
Member

Fixed in #6592

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

Successfully merging a pull request may close this issue.

5 participants