Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Field is not hidden when selection is None #2242

Open
justjam2013 opened this issue Nov 16, 2024 · 2 comments
Open

Field is not hidden when selection is None #2242

justjam2013 opened this issue Nov 16, 2024 · 2 comments
Labels

Comments

@justjam2013
Copy link
Contributor

Describe The Bug

In config-schema.json I have an single select dropdown optionType that is neither required, nor has a default. I then have a second single select dropdown optionOneState which should only display when Option 1 is selected.

When the form is initially displayed, the field optionType shows None as the initial selection and the field optionOneState is also displayed with None as the initial selection. Field optionOneState should be hidden.

            "optionType": {
              "type": "string",
              "oneOf": [
                { "title": "Option 1", "enum": ["optionOne"] },
                { "title": "Option 2", "enum": ["optionTwo"] },
                { "title": "Option 3", "enum": ["optionThree"] }
              ]
            },
            "optionOneState": {
              "type": "string",
              "oneOf": [
                { "title": "Off", "enum": ["off"] },
                { "title": "On", "enum": ["on"] }
              ],
              "condition": {
                "functionBody": "return model.devices[arrayIndices].optionType === 'optionOne';"
              }
            },

If an option is selected in optionType, then optionOneState is shown/hidden as expected:

  • If Option 1 is selected in optionType, field optionOneState is correctly shown
  • If Option 2 is selected in optionType, field optionOneState is correctly hidden
  • If Option 3 is selected in optionType, field optionOneState is correctly hidden

If no option is selected in optionType (shows None as selection in dropdown), then optionOneState is incorrectly shown

I unsuccessfully tried the following for functionBody to hide optionOneState when optionType is None. In all cases, optionOneState is displayed:

    return model.devices?.[arrayIndices]?.optionType?;
    return !model.devices?.[arrayIndices]?.optionType?;
    return !(model.devices?.[arrayIndices]?.optionType?);

    return model.devices[arrayIndices]?.optionType?;
    return !model.devices[arrayIndices]?.optionType?;

    return model.devices[arrayIndices].optionType?;
    return !model.devices[arrayIndices].optionType?;

    return model.devices[arrayIndices].optionType;
    return !model.devices[arrayIndices].optionType;

    return model.devices[arrayIndices].optionType? !== 'undefined';
    return model.devices[arrayIndices].optionType !== 'undefined';

    return model.devices[arrayIndices].optionType? !== undefined;
    return model.devices[arrayIndices].optionType !== undefined;

    return model.devices[arrayIndices].accessoryType? !== '';
    return model.devices[arrayIndices].accessoryType !== '';

Logs

No response

Config

No response

Homebridge UI Version

4.62.1-beta.20

Homebridge Version

1.8.5

Node.js Version

22.9.0

Operating System

macOS

Environment Info

Using hb-service

Raspberry Pi Model

None

Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Dec 17, 2024
@justjam2013
Copy link
Contributor Author

Keeping this open.

@github-actions github-actions bot removed the stale label Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant