Preselect doesn't work with autocomplete field.

Created on 10 January 2022, about 3 years ago
Updated 19 May 2023, almost 2 years ago

Problem/Motivation

When used with autocomplete field, any view can be selected even the ones not select in preselect option, works well with the select list though.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

🇨🇦Canada hansa11

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

Merge Requests

Comments & Activities

Not all content is available!

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

  • 🇮🇹Italy finex

    Thank you, the patch works flawlessly.

  • 🇬🇧United Kingdom scott_euser

    Apologies for missing this. I am just a bit nervous that this is risky as it seems quite likely that there may be cases where site editors have selected a View they are not allowed to select according to 'Preselect View Options'. I suppose it won't break things BUT it would then prevent resave e.g. of a node or paragraph.

    Beyond that we just need test coverage + conversion to merge request to get this in.

  • 🇬🇧United Kingdom scott_euser

    Needs also coordination in case Preselect Views by administrative tags Needs review is merged first to also add that restriction to autocomplete (could also be a separate follow-up issue though)

  • 🇺🇸United States trackleft2 Tucson, AZ 🇺🇸

    It might be safer to move the configuration for this feature, to the field widget settings for the select widget. This approach would ensure that existing widgets (currently only the Select widget) continue to function properly while introducing this as a new option for the Autocomplete widget.

    What are your thoughts?

  • 🇬🇧United Kingdom scott_euser

    Hmmm it's a good suggestion.

    I guess my worry is that choosing which views are available is probably comparably essential as choosing a vocabulary with a taxonomy reference field and DX might suffer hiding it.

    Might anyways be simpler to add support for autocomplete then to handle the update hooks.

  • 🇺🇸United States trackleft2 Tucson, AZ 🇺🇸

    I've added a proof of concept as Merge Request !82 for your consideration.

    The merge request:
    - Incorporates the patch from #2 but uses widget settings instead of field settings.
    - Has an update function to move values from field config to field widget config
    - Adds widget settings for both the select element and the autocomplete widget.

  • Pipeline finished with Failed
    about 1 month ago
    Total: 365s
    #404219
  • Pipeline finished with Failed
    about 1 month ago
    Total: 413s
    #404273
  • Pipeline finished with Failed
    about 1 month ago
    Total: 276s
    #404276
  • 🇬🇧United Kingdom scott_euser

    Hmmm yeah I see how it would work, and thank you for spending the time on it. I think its a fairly big DX change though and I still worry about it then being more hidden.

    Are there other features you feel are specific to the Select widget that justify the separation of controls from autocomplete vs select? Otherwise I can try to insist that any future new feature covers both, allowing us to keep the settings in the field settings (e.g. in Preselect Views by administrative tags Needs review )

    If we do ultimately go down this route, we can sign-post that more controls can be found in the manage form display, but let's not do that yet until we get more of a direction decision (which I am not convinced is needed yet). If we are at a stalemate I can reach out to other maintainers in Drupal Slack to get opinions. Sorry - just nervous as its a very heavily used module

    For anyone else reviewing, updated screenshot:

    Manage form display with proposed change:

    Manage field settings with proposed change:

  • 🇬🇧United Kingdom scott_euser

    FWIW:

    1. I think for the sake of fixing the bug we should get autocomplete to match select like the patch in #2 starts but then also needs tests as per #4.
    2. Then we can move the wider DX change to a follow-up to deal with it in isolation from the bug.
Production build 0.71.5 2024