Skip to content

Conversation

@bfmatei
Copy link
Contributor

@bfmatei bfmatei commented Sep 24, 2025

grafana/grafana#91600

This PR allows clearing default values in panel options. Currently trying to remove a default value would result in no actual change.

A little explanation about the code:

  • the logic to allow clearing out values was already there but it was overwritten by the merge with the getPanelOptionsWithDefaults function
  • previously onOptionsChange was accepting isAfterPluginChange as a parameter
    • this parameter was not doing anything given that, in getPanelOptionsWithDefaults where it was used, it was not affecting options but fieldConfig. This was removed
    • the logic for this was moved to the actual plugin change logic
    • getPanelOptionsWithDefaults call was removed completely from onOptionsChange
📦 Published PR as canary version: 6.40.0--canary.1255.18001595104.0

✨ Test out this PR locally via:

npm install @grafana/[email protected]
npm install @grafana/[email protected]
# or 
yarn add @grafana/[email protected]
yarn add @grafana/[email protected]

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enables clearing default values in VizPanel options by refactoring the options merging logic. Previously, attempts to clear default values had no effect because the merge with default values would override the cleared state.

  • Removed the isAfterPluginChange parameter from onOptionsChange as it wasn't being used correctly
  • Moved the getPanelOptionsWithDefaults call from onOptionsChange to the plugin change logic where it's actually needed
  • Simplified the options change handling to preserve cleared values instead of always merging with defaults

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Collaborator

@torkelo torkelo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we update unit test for this scenario?

@bfmatei
Copy link
Contributor Author

bfmatei commented Sep 25, 2025

@torkelo - absolutely! Fixed the test and added an additional one.

@bfmatei bfmatei self-assigned this Sep 25, 2025
@bfmatei bfmatei added minor Increment the minor version when merged release Create a release when this pr is merged labels Sep 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor Increment the minor version when merged release Create a release when this pr is merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants