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

Template field: Unexpected behavior when only one template is available for the specific post type. #68173

Open
2 of 6 tasks
gigitux opened this issue Dec 20, 2024 · 5 comments · May be fixed by #67872
Open
2 of 6 tasks
Assignees
Labels
[Package] Fields /packages/fields [Type] Bug An existing feature does not function as intended

Comments

@gigitux
Copy link
Contributor

gigitux commented Dec 20, 2024

Description

Different templates can be assigned based on the post type. If only one template is available, the “Swap Template” dialog opens without any content.

The Post Editor handles these cases, hiding the “Swap Template” option.

Only template Available Multiple templates Available
Screen.Capture.on.2024-12-20.at.10-34-54.mp4
Screen.Capture.on.2024-12-20.at.10-36-32.mp4

Step-by-step reproduction instructions

  1. Ensure that add Quick Edit experiment is enabled.
  2. Enable this theme emptytheme.zip
  3. Visit wp-admin/site-editor.php?p=%2Fpage&layout=table&quickEdit=true
  4. Select a page.
  5. Edit the template.
  6. Click on swap template.
  7. See that dialog is opened but without any content.

Screenshots, screen recording, code snippet

Screen.Capture.on.2024-12-20.at.10-28-06.mp4

Environment info

No response

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

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure
@gigitux gigitux added [Package] Fields /packages/fields [Type] Bug An existing feature does not function as intended labels Dec 20, 2024
@gigitux
Copy link
Contributor Author

gigitux commented Dec 20, 2024

@jameskoster can you take a look at this issue? How should we handle this case?

@gigitux
Copy link
Contributor Author

gigitux commented Dec 20, 2024

Syncing with @louwie17, I discovered that this issue will be addressed via #67872
With this PR, when the available template is only one, we “disable” the template field:

Screen.Capture.on.2024-12-20.at.10-51-21.mp4

@jameskoster What do you think? Does it make sense or you have another idea? Thanks! 🙇

@jameskoster
Copy link
Contributor

I reckon this is okay as a start. In the future this could be an entry point to create a new template.

Out of curiosity what happens if there's a mixture of records that can/cannot have their templates swapped in the selection? For example when entity-specific templates exist (e.g. page-$id).

@gigitux
Copy link
Contributor Author

gigitux commented Dec 20, 2024

I reckon this is okay as a start. In the future this could be an entry point to create a new template.

Thanks for the feedback! I will link this issue to the linked PR, so once it will be merged, this issue will be closed 👍

Out of curiosity what happens if there's a mixture of records that can/cannot have their templates swapped in the selection? For example when entity-specific templates exist (e.g. page-$id).

Are you referring to the bulk editing? @louwie17 improved the logic with #67584

Yes, only the templates available across all the selected records will appear in the dialog.

@jameskoster
Copy link
Contributor

Are you referring to the bulk editing?

Yes exactly.

Yes, only the templates available across all the selected records will appear in the dialog.

Nice :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Fields /packages/fields [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants