Uploaded image for project: 'Magnolia UI'
  1. Magnolia UI
  2. MGNLUI-6740

Combobox with custom datasource will not show selected value

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Neutral
    • Resolution: Fixed
    • Affects Version/s: 6.2.7
    • Fix Version/s: None
    • Component/s: forms
    • Labels:
      None
    • Environment:
      Ubuntu

      Description

      Steps to reproduce

      1.  Create a custom data source for the combobox options like so
      @DatasourceType("anchorsDatasource")
      public class AnchorLinkSelectFieldSupport extends OptionSelectFieldSupport {
      
          private final LinkService linkService;
      
          @Inject
          public AnchorLinkSelectFieldSupport(final FieldDefinition fieldDefinition, final OptionListDefinition optionListDefinition, final LinkService linkService) {
              super(fieldDefinition, optionListDefinition);
              this.linkService = linkService;
          }
      
          @Override
          public DataProvider<Option, ?> getDataProvider() {
              final var noneOption = new Option();
              noneOption.setValue("");
              noneOption.setLabel("None");
      
              // one may use a set of hard coded items to reproduce this issue
              final var options = Stream.concat(
                  Stream.of(noneOption),
                  linkService.getAnchorsDefinedInPage(null).stream()
                      .map(anchor -> OptionUtil.of(anchor, anchor))
              );
      
              return DataProvider.fromStream(options);
          }
      }
      
      1. Register it:
      <components>
          <id>datasource-anchors</id>
          <component>
              <type>info.magnolia.ui.field.SelectFieldSupport</type>
              <implementation>my.project.dialog.field.AnchorLinkSelectFieldSupport</implementation>
          </component>
      </components>
      1.  Then use it in a dialog:
      anchorTarget:
        label: fields.anchorTarget
        $type: comboBoxField
        datasource:
          name: anchors

      Expected results

      When creating a component which uses this field, the dialog should show the selected value.

      Actual results

      No value is shown even though it is correctly stored:

       

        Checklists

        Acceptance criteria

          Attachments

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              martyglaubitz Marty Glaubitz
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Date of First Response:

                  Checklists

                  Bug DoR
                  DoD