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

[UX] Fixed: Set the default value for "Layout template" to what is in use on the default layout. #6479

Closed
jenlampton opened this issue Apr 26, 2024 · 16 comments · Fixed by backdrop/backdrop#4711

Comments

@jenlampton
Copy link
Member

jenlampton commented Apr 26, 2024

When you create a layout from the layouts listing page currently, you are asked for the layout template every time.

Many of us regularly forget to select a template on this step (causing an immediate validation error when we enter the path).

Screenshot 2024-04-26 at 2 33 42 PM

The reason we forget to select a template so often is because which template is in use is not even something we're thinking about -- because it's not relevant to our current task: placing blocks on the page.

This could be solved if the "Layout template" question had a default value.

@yorkshire-pudding suggested:

the template used in the default layout should be selected by default

Yes please :)

@jenlampton jenlampton changed the title Set the default value for "Layout template" to the same template that's in use on the default layout. [UX] Set the default value for "Layout template" to the same template that's in use on the default layout. Apr 26, 2024
@jenlampton
Copy link
Member Author

I've filed a quick PR with a few line change.

+  if ($layout->layout_template != NULL) {
+    $layout_template = $layout->layout_template;
+  }
+  else {
+    $layout_template = config_get('layout.layout.default', 'layout_template');
+  }
   $form['layout_template'] = array(
     '#title' => t('Layout template'),
     '#type' => 'radios',
-    '#default_value' => $layout->layout_template,
+    '#default_value' => $layout_template,
     '#options' => array(),

@stpaultim
Copy link
Member

stpaultim commented Apr 26, 2024

I'm a bit surprised that there is not an existing issue for this. It's a bit of a pet peeve of mine as well. This seems like a simple and useful solution!

Works for me.

@jenlampton
Copy link
Member Author

I'm a bit surprised that there is not an existing issue for this.

Same! It's been bothering me for so long I can't believe I hadn't created one before now :)

@klonos
Copy link
Member

klonos commented Apr 26, 2024

Indeed, that seems like a non-brainer that should be in place from the start 👍🏼

@klonos
Copy link
Member

klonos commented Apr 26, 2024

I've tested this and it works like a charm! Thanks @jenlampton 🙏🏼 ...and thank you @yorkshire-pudding for the brilliant idea ❤️

I've reviewed the code and it looks good (only left a suggestion for an inline comment to be added to explain what we are doing and why).

Here's what I've tested:

  1. create a new layout -> confirm that the default template is pre-selected 👍🏼
  2. change the template used in the default layout -> create a new layout -> new template is pre-selected 👍🏼
  3. edit the layout created in step 1. above -> the template that the layout was saved with is still in use (not accidentally reverting to the template of the default layout)

So this works as expected when creating new and when editing existing layouts 👍🏼 ....RTBC (minus the pending addition of the inline comment, which is totally up to you @jenlampton )

@jenlampton
Copy link
Member Author

jenlampton commented Apr 26, 2024

left a suggestion for an inline comment

Comment added. I also just added tests, so no rejecting by core devs! (I hope)

@klonos
Copy link
Member

klonos commented Apr 26, 2024

One spelling nag in the new test. ...the rest of the CSpell nags should be addressed separately in #6302

@jenlampton
Copy link
Member Author

jenlampton commented Apr 26, 2024

Fixed the spelling error, and some other PHPCS failures that seemed legit.

@klonos
Copy link
Member

klonos commented Apr 26, 2024

@jenlampton there are some CSS changes that seem to have creeped in from your local now.

@jenlampton
Copy link
Member Author

Gah, sorry. I managed to pull those out last time and then they snuck in again. removed!

@klonos
Copy link
Member

klonos commented Apr 26, 2024

Yeah, I think that things like that usually happen when you have not rebased/pulled. Checking again 👀

@klonos
Copy link
Member

klonos commented Apr 26, 2024

This is RTBC again 👍🏼 ...minus a small suggestion to use single instead of double quotes in some text.

@bugfolder
Copy link

bugfolder commented Apr 27, 2024

A big peeve of mine is forms that throw validation errors before I've finished filling them out, so I'm very happy to see this.

@klonos
Copy link
Member

klonos commented Apr 27, 2024

If people like this change, then please review/test the PR for #6480 as well.

@argiepiano
Copy link

Love it!

@quicksketch
Copy link
Member

This is such an incredibly good fix! I can't believe we've made people click an option and encounter that AJAX error for so long. Great idea @jenlampton!

Thanks everyone, I've merged backdrop/backdrop#4711 into 1.x and 1.27.x.

@jenlampton jenlampton changed the title [UX] Set the default value for "Layout template" to the same template that's in use on the default layout. [UX] Fixed: Set the default value for "Layout template" to what is in use on the default layout. May 16, 2024
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.

6 participants