Remove token_browser from saved configuration of formatter

Created on 22 June 2023, about 1 year ago
Updated 8 July 2023, 12 months ago

Problem/Motivation

When we save formatter settings, in configuration there is `token_browser: ''` added to `more` section of config. This results in `missing schema` error from Configuration Inspector β†’ module.

Steps to reproduce

Enable module, use formatter for any field. Check updated configuration.

Proposed resolution

Change form element type from `item` to `container`, so form API doesn't assume it as a part of configuration.

Remaining tasks

Review the patch, accept it or propose another solution.

πŸ› Bug report
Status

Fixed

Version

2.1

Component

Code

Created by

πŸ‡·πŸ‡ΊRussia ilya.no

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

Comments & Activities

  • Issue created by @ilya.no
  • First commit to issue fork.
  • Assigned to markie
  • Status changed to Needs review about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States ultimike Florida, USA

    @ilya.no - thanks for reporting this and the patch.

    I suggest we follow the pattern that the Pathauto module uses:

          $form['pattern_container']['token_help'] = [
            '#theme' => 'token_tree_link',
            '#token_types' => $alias_type->getTokenTypes(),
          ];

    Removing '#type' => 'item' from the form in Smart Trim seems to do the trick as well.

    I tried writing a test for this, but it seems rather pointless, IMHO. For example, in a functional test, we'd have to do something like this:

    $display_repository->getViewDisplay('node', 'article')
          ->setComponent('body', [
            'type' => 'smart_trim',
            'settings' => [
              'trim_length' => 100,
              'trim_type' => 'chars',
              'summary_handler' => 'trim',
              'more' => [
                'display_link' => TRUE,
                'class' => 'more-link',
                'link_trim_only' => FALSE,
                'target_blank' => 0,
                'text' => 'More',
                'aria_label' => 'Read more about [node:title]',
                'token_browser" => '',
              ],
            ],
          ])
          ->save();

    and then test for the existence of `token_browser` in config. Then, we'd have to remove `token_browser` from the code above and then test for its non-existence in config. Otherwise, we'd have to create a functional javascript test to simulate the process of saving Smart Trim config from the UI, then testing for `token_browser` in config. Personally, I don't think it is worth the time, as this is a pretty straight-forward fix.

    I've created a MR for this fix.

    -mike

  • @ultimike opened merge request.
  • First commit to issue fork.
  • Status changed to Fixed 12 months ago
  • πŸ‡ΊπŸ‡ΈUnited States markie Albuquerque, NM

    looks good.. merging in and marking as fixed/

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

Production build 0.69.0 2024