Closed (fixed)
Project:
Drupal core
Version:
11.x-dev
Component:
comment.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
11 Jul 2023 at 15:13 UTC
Updated:
4 Nov 2024 at 18:20 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
lauriiiComment #4
lauriiiComment #5
keshavv commentedYes, The issue that you mentioned in the description is exist. It's showing the validation message that you need to select one option.
The patch that you provided is working perfectly. I think we can go wit it.
Before patch.


After patch.

Comment #6
keshavv commentedComment #7
catchI have one question - what happens if an entity has no comments + comments closed before this patch is applied, - won't the selected option be hidden then? We might need to to only hide the option if it doesn't match the current value, or.. something.
Comment #8
lauriiiBefore if you had selected hidden (for example because it's default value), it would not be shown in the UI. There would also be no way to select hidden when you have no comments because of 🤷♂️
After the patch, "Closed" will be displayed always when it's the current value (set in #default_value). However, if it's not the currently selected option, it's hidden when there are no comments because it doesn't make sense to have this state in that use case. Why would you display an empty comment section (without a way to comment) instead of hide it if there are no comments?
Comment #9
catchThat makes sense now, so we're fixing the issue I was worried about introducing here.
Also committed the issue this was spun out of.
Comment #10
lauriiiRerolled #4 on top of #3373867: [regression] "Comments field is required" when creating content for types with a comment field configured as hidden.
Comment #12
catchCommitted f680053 and pushed to 11.x. Thanks!
Comment #14
drpldrp commentedThis change affects migration.
It can cause required comment field on node edit form to display no default value.
Attached example image is node edit form comment field for a migrated node that had comment=1 (Closed).
There's a type mistmatch between $element['status']['#default_value'] and CommentItemInterface::CLOSED.
Maybe just cast the prior to int, or it's probably okay to not use strict comparison !=.
Comment #15
drpldrp commentedComment #16
lauriii@drpldrp It would be helpful if you could file a new issue, and link it from here 🙏
Comment #17
drpldrp commented