# @OptionalWidget for Enum?

**URL:** <https://forum.knime.com/t/optionalwidget-for-enum/90291>\
**Category:** Node Development\
**Created:** [October 24, 2025, 9:34am UTC](https://forum.knime.com/t/optionalwidget-for-enum/90291 "2025-10-24T09:34:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![niederle](https://forum-cdn.knime.com/user_avatar/forum.knime.com/niederle/32/42_2.png) [@niederle](https://forum.knime.com/u/niederle)\
**Post date:** [October 24, 2025, 9:34am UTC](https://forum.knime.com/t/optionalwidget-for-enum/90291/1 "2025-10-24T09:34:44Z")

</div>

Hi,

I try to provide a drop down list as an optional widget in my node settings. First question: Should that be possible? If not, I could still use a `@ValueSwitchWidget` to show or hide my setting.

If yes, let me describe the issue:

I tried the following optional widgets. The first one (string value) works as expected while the second one (enum value) does show the checkbox but nothing else (no matter if checked or not).

```java
	
	@Widget(title = "Optional One", description = "...")
	@OptionalWidget(defaultProvider = Opt1DefaultProvider.class)
	Optional<String> m_opt1;
	
	static final class Opt1DefaultProvider implements DefaultValueProvider<String> {

        @Override
        public String computeState(final NodeParametersInput context) throws StateComputationFailureException {
            return "optional 1 value";
        }

    }
	
	@Widget(title = "Optional Two", description = "...")
	@OptionalWidget(defaultProvider = Opt2DefaultProvider.class)
	Optional<Opt2Enum> m_opt2;
	
	static final class Opt2DefaultProvider implements DefaultValueProvider<Opt2Enum> {

        @Override
        public Opt2Enum computeState(final NodeParametersInput context) throws StateComputationFailureException {
            return Opt2Enum.TWO;
        }

    }
	
	enum Opt2Enum {
        @Label("one")
        ONE,

        @Label("two")
        TWO,
        
        @Label("three")
        THREE;
	}

```

When checking the checkbox of the second widget, I get the following error:

```auto
ERROR main KnimeBrowserView TypeError: Cannot use 'in' operator to search for 'includeUnknownValues' in TWO (source: https://org.knime.core.ui.dialog/uiext/defaultdialog/dist/NodeDialogApp-sQeR6LBA.js; line: 1267)
ERROR main KnimeBrowserView TypeError: Cannot read properties of undefined (reading 'initResizeHeight') (source: https://org.knime.core.ui.dialog/uiext/defaultdialog/dist/NodeDialogApp-sQeR6LBA.js; line: 1267)

```

I would be happy if anyone can help.

Antje

---

<div class="post-metadata">

**Author:** ![robin\_gerling](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/r/f05b48/32.png) [@robin\_gerling](https://forum.knime.com/u/robin_gerling)\
**Post date:** [November 3, 2025, 8:21am UTC](https://forum.knime.com/t/optionalwidget-for-enum/90291/2 "2025-11-03T08:21:04Z")

</div>

Hi @niederle,

This appears to be a bug. I’ve created a ticket for it (internal reference: UIEXT-3028).  
In the meantime, you can work around the issue by attaching a `ChoicesProvider` to the field. The provider should return all enum values.

```java
@Widget(title = "Optional Two", description = "...")
@OptionalWidget(defaultProvider = Opt2DefaultProvider.class)
@ChoicesProvider(Opt2Provider.class)
Optional<Opt2Enum> m_opt2 = Optional.empty();

static final class Opt2Provider implements EnumChoicesProvider<Opt2Enum> {
    @Override
    public List<Opt2Enum> choices(final NodeParametersInput context) {
        return Arrays.asList(Opt2Enum.values());
    }
}

```

Best,  
Robin

---

<div class="post-metadata">

**Author:** ![niederle](https://forum-cdn.knime.com/user_avatar/forum.knime.com/niederle/32/42_2.png) [@niederle](https://forum.knime.com/u/niederle)\
**Post date:** [November 3, 2025, 1:10pm UTC](https://forum.knime.com/t/optionalwidget-for-enum/90291/3 "2025-11-03T13:10:14Z")

</div>

Thank you very much for your proposal how to solve the issue. It works! 🙂

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [November 10, 2025, 1:10pm UTC](https://forum.knime.com/t/optionalwidget-for-enum/90291/4 "2025-11-10T13:10:52Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
