Problem/Motivation

When editing a content type with a media field and the user makes an error, the message at the top of the screen shows that it has an
error but it does not highlight the field as with other fields

Steps to reproduce

Create a content type with a mandatory media field
Create a new item of content of this type but fail to add a media item.
Click on save and see that the error is reported at the top but that the field is not highlighted in a red border with red label text as other field types.

Proposed resolution

The 'error' class is added to the media field upon validation error, yet the associated styles for the 'error' class are not correctly applied. Update the CSS to fix the issue.

Remaining tasks

  • Update CSS to fix highlighting issue: Done
  • Add a new test to ensure that 'error' class gets added properly to media field during validation errors: Done
  • Test: Done
  • Review
  • Merge

User interface changes

Media fields are correctly flagged when in error.

Before patch

After patch

API changes

None.

Data model changes

None.

Release notes snippet

N/A

Issue fork drupal-3396669

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Rory Downes created an issue. See original summary.

Aditi Saraf made their first commit to this issue’s fork.

rory downes’s picture

StatusFileSize
new2.41 KB

The proposed resolution was wrong as it turns out. This class is being applied correctly. It needed some changes to fieldset and form styling to make sure that such a field has the star when mandatory and goes red when the has-error class is added by existing code.

I attach a patch to make these changes that worked for the site where I spotted this issue.

shweta__sharma’s picture

Status: Active » Needs review
smustgrave’s picture

Version: 10.1.x-dev » 11.x-dev
Status: Needs review » Needs work
Issue tags: +Needs tests

Thank you for reporting. Moving to 11.x as the current dev branch.

Could we have a simple assert to verify the classname is appearing correctly.

sir-arturio’s picture

Taking this on. (Hello from Drupal Contribution Sprints Helsinki!)

sir-arturio’s picture

Was able to commit the patch to the merge request(?) branch. Had problems setting up the contrib environment. Maybe next time!

rory downes’s picture

This has been moved to the 11.x branch as that is the current dev branch. However, my patch failed to apply against 11.x and I have not had time to fix that

ameymudras made their first commit to this issue’s fork.

ameymudras’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work

Was previously tagged for tests which are still needed.

akhil babu’s picture

Assigned: Unassigned » akhil babu
akhil babu’s picture

akhil babu’s picture

Assigned: akhil babu » Unassigned
Status: Needs work » Needs review

Added tests as per #5. Not sure why spell check is failing. No spell check error in local
Only local images are allowed.

Akhil Babu changed the visibility of the branch 3396669-has-error-2 to hidden.

smustgrave’s picture

Status: Needs review » Needs work

May need a rebase but other issues don’t seem to be having it so something that needs to be looked at before it can be merged

akhil babu’s picture

Status: Needs work » Needs review

Thanks @smustgrave. Rebasig fixed the pipeline.
Moving to needs review

smustgrave’s picture

Status: Needs review » Needs work

before/after screenshots should be included in Issue summary.

Tests pass without the change so either the test is off or the title is wrong, is the class not being added or is the styling not being added? Based on the answer will need a title/issue summary update to be clear.

Screenshots should be added either way.

gauravvvv’s picture

Added before and after patch screenshot in the issue summary

Before patch

After patch

akhil babu’s picture

Title: has-error class not applied to media fields » Media fields are not highlighted during validation errors.
Issue summary: View changes
akhil babu’s picture

Status: Needs work » Needs review

Thanks @smustgrave ,@Gauravvvv . The title was indeed incorrect. Updated the title and issue summary.
Moving back to needs review.

sandeep_k’s picture

StatusFileSize
new61.83 KB
new93.46 KB

Verified and tested patch MR !5371 mergeable on Drupal version- 11.0-dev. The patch was applied successfully and looks good to me.
Testing Steps:

  1. Install Media module
  2. Create a Content type & add a media field, make this field mandatory.
  3. Go to content & add new content> Leave media field and save to reproduce. (Shared before results)
  4. Download this patch and Apply.
  5. Go back to Add Content and Reverify.

Testing Results:
Now the media field is getting highlighted, sharing after patch results.

We can move this ticket to RTBC.

smustgrave’s picture

Status: Needs review » Needs work

Then the test can be removed as it's not testing anything with this issue.

gauravvvv’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs tests

quietone made their first commit to this issue’s fork.

quietone’s picture

Issue tags: +Usability

I'm triaging RTBC issues. I read the IS and skimmed comments. The IS explains what this is about and there are before/after screenshots. All very helpful! I didn't find any unanswered questions.

This changes the UI so needs to be tagged for usability. I am adding the tag.

I tested this today on Drupal 11.x, standard install, using the steps in the issue summary. My results agree with what is in the issue summary.

There is a failing test, Drupal\Tests\media\FunctionalJavascript\MediaSourceOEmbedVideoTest so I pressed 'rebase' in Gitlab which will start the tests again.

shweta__sharma’s picture

Status: Reviewed & tested by the community » Needs work

Merge blocked needs to be rebased

gauravvvv’s picture

Status: Needs work » Needs review
shweta__sharma’s picture

Rebased the MR

shweta__sharma’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new126.26 KB

I tested on Drupal 11.x changes are done as mentioned in the Issue summary now the Media fields are highlighted during validation errors.

Attached screenshot for reference.

after-patch

Thanks

nod_’s picture

Status: Reviewed & tested by the community » Needs work

couple questions

saurav-drupal-dev’s picture

StatusFileSize
new4.8 MB

issue not fixed please check the attachment.

no issue found

Steps followed
Create a content type with a mandatory media field
Create a new item of content of this type but fail to add a media item.
Click on save and see that the error is reported at the top but that the field is not highlighted in a red border with red label text as other field types.

sheetal.pathak’s picture

StatusFileSize
new63.14 KB

Tested changes are done as mentioned the Media fields are highlighted during validation errors.
Versions tested on
Drupal - 11.x-dev
Drupal - 11.2

1. Set Claro theme.
2. Create a content type -> Add media field ->make it mandatory.
3. Create a new item of content of this type but dont add media item.
4. Save. Error is highlighted with red border.

Can be moved to RTBC+

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

quietone’s picture

Title: Media fields are not highlighted during validation errors. » Media fields are not highlighted during validation errors
Status: Needs work » Postponed

The Claro theme was approved for removal in #3576460: [policy, no patch] Deprecate and remove Claro.

This is Postponed. The status is set according to two policies. The Remove a core extension and move it to a contributed project and the Extensions approved for removal policies.

The deprecation work is in #3576668: [meta] Tasks to deprecate Claro and the removal work in #3584638: [meta] Tasks to remove the Claro theme.

smustgrave’s picture

Project: Drupal core » Claro
Version: main » 3.0.x-dev
Component: Claro theme » Code
Status: Postponed » Needs work

Claro has moved to contrib