Multiple warning messages when having untranslatable fields

Created on 26 September 2018, over 6 years ago
Updated 26 June 2024, 6 months ago

Problem/Motivation

While working with content moderation and the paragraphs module. Having some paragraphs with untranslatable fields, and collapsing the paragraphs, after the ajax event we get a duplicated Fields that apply to all languages are hidden to avoid conflicting changes over the paragraph field.

After an ajax action:

This also happens with just Drupal Core after saving a node:

The problem is that drupal_set_message() should not be used in form builders/alters as it's unpredictable when it runs.. An initial submit without an ajax action first results in the form being built again as does every form rebuild, typically done on ajax actions.

Proposed resolution

Convert the message to a render array.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

11.0 🔥

Component
Content translation 

Last updated 9 days ago

No maintainer
Created by

🇧🇴Bolivia johnchque Bolivia

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States smustgrave

    From what I can tell the points in #21 have not been addressed/answered. Maybe @berdir answers #21.2

    Tagging for usability review for the phrase.

  • Status changed to Needs review over 1 year ago
  • last update over 1 year ago
    29,822 pass, 1 fail
  • 🇨🇭Switzerland berdir Switzerland

    I discussed this a bit with @laurii at DevDays23 and he pointed me to the fact that something very similar has been done in \Drupal\ckeditor5\Plugin\Editor\CKEditor5::buildConfigurationForm() if for slightly different reasons. But I think that would have similar problems as well with the message repeating on submit and ajax operations.

    I still think it makes sense to solve this bug and then think about a generic solution or not using warning messages for this at all. We discussed that the new toggletip might give us some points.

    I also cleaned up the patch and removed a lot of unrelated changes and I removed the $form_state check, that should indeed not be required anymore.

  • last update over 1 year ago
    Custom Commands Failed
  • 🇨🇭Switzerland berdir Switzerland

    Cleaned up a the kernel test, the previous fix did work before, but only because it didn't actually test the display message part anymore. Now with the removed form state checks, the previous two cases also had the message form element, I fixed them and removed the logic for display warning completely.

    No fond of those kind of tests, I don't think they're testing much and are hard to understand and maintain.

    Removing the needs usability review tag. I don't think there's something to review here, that you no longer get duplicated messages or a message after saving the node doesn't needs a usability review. The issue that would need one is the follow-up that I created that wants to use a different pattern than warning messages for this.

  • last update over 1 year ago
    Custom Commands Failed
  • 🇨🇭Switzerland berdir Switzerland

    Ok, we can actually clean up quite a bit more in that test as we no longer need those two flags at all.

  • last update over 1 year ago
    29,871 pass
  • 🇨🇭Switzerland berdir Switzerland

    meh.

  • Status changed to RTBC over 1 year ago
  • 🇺🇸United States smustgrave

    Ran the tests without the fix and got

    ContentTranslationUntranslatableFieldsTest

    Behat\Mink\Exception\ResponseTextException : The text "Fields that apply to all languages are hidden to avoid conflicting changes." appears in the text of this page, but it should not.
    

    ContentTranslationHandlerTest passes without issue.

    The fix matches the IS of transforming message to array.

    Think this is good!

    • lauriii committed 29ae2445 on 11.x
      Issue #3002571 by johnchque, Berdir, kishor_kolekar, ravi.shankar,...
  • Status changed to Fixed over 1 year ago
  • 🇫🇮Finland lauriii Finland

    Committed 29ae244 and pushed to 11.x. Thanks!

    Not backporting to 10.1.x because of the small behavior change here.

  • 🇫🇮Finland lauriii Finland

    I updated the code comment on commit. Here's interdiff for that.

  • Automatically closed - issue fixed for 2 weeks with no activity.

  • Status changed to Fixed 6 months ago
  • 🇮🇳India kavbiswa

    Patch updated for 10.2.x branch.

Production build 0.71.5 2024