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

[4.x]: Fields using Cp::elementSelectFieldHtml force element draft creation #11242

Closed
rynpsc opened this issue May 16, 2022 · 2 comments
Closed

Comments

@rynpsc
Copy link
Contributor

rynpsc commented May 16, 2022

What happened?

Description

When including a field within a custom element that uses Cp::elementSelectFieldHtml, certain changes to the field will cause Craft to create a draft even if the element isn't utilising trackChanges or canCreateDrafts or hasRevisions.

This leads to further errors as the element isn't set up to handle drafts and attempts to discard changes won't succeed.

Steps to reproduce

  1. Create a new element type that overrides canView and canSave to return true, give the element a field layout and add a both text field and an element field e.g. Entries to the field layout. Giving the element a metafield using Cp::elementSelectFieldHtml also works.
  2. Create a new element using the type in step 1 and make some changes to the text field to observe the lack of draft/change tracking.
  3. Using the element field, select an element and then remove it. Removal of the element will trigger the creation of a draft.

As the draft is only created on removal of the element from the field I'm assuming it's Cp::elementSelectFieldHtml where the issue lies rather than my implementation but I could be wrong.

craftv4-element-select-bug.mov

Expected behavior

Changes to custom fields and metafields using Cp::elementSelectFieldHtml do not trigger draft creation.

Actual behavior

Changes to custom fields and metafields using Cp::elementSelectFieldHtml do trigger draft creation.

Craft CMS version

Craft Pro 4.0.2

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

No response

@rynpsc rynpsc changed the title [4.x]: Field using Cp::elementSelectFieldHtml force element draft creation [4.x]: Fields using Cp::elementSelectFieldHtml force element draft creation May 17, 2022
@brandonkelly
Copy link
Member

Thanks for reporting that! Fixed now for the next release.

@brandonkelly
Copy link
Member

Craft 4.0.3 is out now with that fix.

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

No branches or pull requests

2 participants