Problem/Motivation

The icon picker field, when set to "Optional," offers an "empty" option. However, selecting "empty" and saving the content results in the first option being selected instead. Additionally, the "empty" option is not present within the input field itself, as revealed by inspecting the code..

Proposed resolution

In the file Element/FontIconpicker.php, line 34 introduces the processFontIconpicker function. However, this function executes after the processSelect function, preventing the "empty" option from being added to the input field.

To address this issue, modify line 34 as follows:

$info['#process'] = array_merge([[$class, 'processFontIconpicker']], $info['#process']);

This code effectively merges the processFontIconpicker function into the existing #process array, ensuring it runs before processSelect. This, in turn, guarantees the successful addition of the "empty" option to the input field.

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

    Yannick Bloemen created an issue. See original summary.

    viren18febs’s picture

    Status: Active » Needs review
    StatusFileSize
    new561 bytes

    I have added a patch for this , please review.

    chiragp185’s picture

    Status: Needs review » Reviewed & tested by the community

    • ba6ee3fa committed on 1.0.x
      Issue #3425667 by viren18febS, Yannick Bloemen, chiragkparikh: Unable to...
    s3b0un3t’s picture

    Status: Reviewed & tested by the community » Fixed

    Hello,

    Thank you to all three for this feedback, the patch and the tests.

    I tested it on my side and everything seems ok.

    I apply the patch and generate a new release.

    s3b0un3t’s picture

    Version: 1.1.0 » 1.1.1
    Status: Fixed » Closed (fixed)