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

Show yaml parsing errors in hui-element-editor #23690

Merged
merged 1 commit into from
Jan 14, 2025

Conversation

karwosts
Copy link
Contributor

@karwosts karwosts commented Jan 11, 2025

Proposed change

If there are yaml errors in a card editor, show those errors in the window.

Currently they are not shown, and if we click "Save", the window closes and any pending changes are lost. The only indication of an error is a red line on the side of the codemirror box, which is not always obvious to every user what it means.

This change shows yaml errors in the window, and disables the save button when there are yaml errors.

I have also elected to do a bit of debouncing on this detection, because if we just show the error immediately, it will show an error immediately every time a user types a keystroke on a new line, which I think is too aggressive.

So this only shows the error either after user pauses typing for 2 seconds, or when the codemirror box is blurred.

image

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example configuration

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue or discussion:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

@karwosts
Copy link
Contributor Author

It's also possible that some of this error display should go directly into ha-yaml-editor itself, instead of being handled by every parent that instances one. Though in different contexts we may display errors in different ways or styles (e.g. fullscreen automation it is delivered by toast on save, vs ha-alert). Or we may need to respond to errors in different ways.

@MindFreeze MindFreeze merged commit eda0ea0 into home-assistant:dev Jan 14, 2025
16 checks passed
@karwosts karwosts deleted the yaml-errors-element-editor branch January 14, 2025 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants