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

Combobox with custom datasource will not show selected value

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Neutral Neutral
    • None
    • 6.2.7
    • forms
    • None
    • Ubuntu

      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:

       

        Acceptance criteria

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

                Created:
                Updated:
                Resolved:

                  Bug DoR
                  Task DoD