-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Don't add default content to grids #4177
Conversation
Yo @kjac Sorry, running out of greetings for you. I might google some for the next PR. We'll test and all that and then merge if it's all gravy. Em |
Hah! You do that 😋 |
Had a look at the old commits and it looks like the intention was: "you only have 1 choice anyway, so let's get you started immediately". We'll discuss in out regular meetings at HQ and get back to you! |
@nul800sebastiaan sounds very much in line with the code I went through working on this PR. It's a valid argument. But I think the HasValue() counter argument is a better one 😄 |
Haha yeah, but the question is: why should we store anything if there's nothing actually added to the grid. Also, the question is: do we want to keep helping people with one less click when they create a new page with a grid with only 1 option. Probably yes. And if we can do that without storing values as long as they don't add anything to that grid then that's probably the way to go. |
Sounds legit. I'll think of something... surely it should be possible to give everyone the best of both worlds. |
@nul800sebastiaan so I've been digging a bit more into this. And I can't see how we can support both "add default content" and "don't save default content" or "don't let default content count towards HasValue". The grid will automatically add the first row if you have only one row config. If that row config allows only one editor, this editor will also automatically be chosen. And therein lies the issue: It's going to be a pain to figure out if the default row + editor combo constitutes an "empty" value, considering that any given editor not necessarily needs an input value to render something meaningful in the frontend. On another note: When I add another row, shouldn't the grid automagically pick the one and only row applicable config? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kjac We had a chat about this at HQ this week and the behavior is almost correct:
- If there's only ONE possible layout, then automatically choose that layout
- Then after that it is fine to give the "Add row" choice instead of adding the only possible row
That makes sure we'll never add an empty editor that is never used and this whole problem is solved. Can you update please? 😁
@nul800sebastiaan I tried to explain this in my last comment:
This leaves us with the following options:
Choices, choices... which to choose? I think 2 is the worst option of the three 🤔 |
@kjac #2 is exactly what we would love! 👍 The idea is: you have only 1 layout choice and after looking at people's implementations for a few years: that's usually the case. So then you don't need to show it as a choice. Most of the times the next step would be adding a row and most people will have 2 or 3 row choices, so it would always be something they'd need to choose anyway. If there's only 1 row choice then it's not so bad to make it a deliberate choice to add something. And it solves the issue of adding something "empty" that will look weird afterwards. |
@nul800sebastiaan so... after even more digging into this, it turns out we can't exactly do option 2 very elegantly. Long story short: When we have an "empty" (default) grid, we have to pass a null value to the server in |
Hey there @kjac ! I'm writing today after announcing at Codegarden, our yearly conference, that the upcoming version 7.15.0 will be the last Umbraco v7 release with new features in it. From now on all our efforts will be focused on version 8 instead. 🎱 We're wrapping up the 7.15 version at the moment and unfortunately these proposed changes won't be able to make it in there. We'd like to extend a big thank you the efforts on this so far and we would love it if you could have a look at porting this feature over to v8 instead. Of course if you have any questions on where to start then feel free to ask on the forum, we monitor all questions there and we're happy to assist. Thanks again for the work in this PR and we hope to see you contributing to v8 some time soon! Best, Sebastiaan and the Umbraco CMS team. |
Prerequisites
If there's an existing issue for this PR then this fixes: #4154
Description
As described in #4154 the grid misbehaves when the grid configuration has only one grid layout and one row configuration - like this:
Given that configuration, the grid property editor adds a default value to the grid - like this:
With this PR applied, the same operation looks like this:
Testing this PR
Model.Content.HasValue("[gridPropertyAlias]")
returns false when the page is rendered.