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

fix(panel-menu): menu throwing error in logs table #968

Merged
merged 1 commit into from
Dec 19, 2024

Conversation

svennergr
Copy link
Contributor

Opening panel menu was throwing an error in Logs Table because no VizPanel ancestor could be found. Interestingly findObjectOfType returned a VizPanel instance, but sceneGraph.getAncestor threw an error.

Change the behavior to always use sceneGraph.getAncestor and catch the error in case there's not VizPanel.

@svennergr svennergr added the bug Something isn't working label Dec 19, 2024
@svennergr svennergr requested a review from a team as a code owner December 19, 2024 10:53
@@ -59,22 +59,6 @@ export class PanelMenu extends SceneObjectBase<PanelMenuState> implements VizPan
constructor(state: Partial<PanelMenuState>) {
super({ ...state, addExplorationsLink: state.addExplorationsLink ?? true });
this.addActivationHandler(() => {
const viz = findObjectOfType(this, (o) => o instanceof VizPanel, VizPanel);
Copy link
Contributor

Choose a reason for hiding this comment

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

We should expect that findObjectOfType doesn't find what we're looking for and account for that case. Similar to when we use Array.find().

Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't the problem here that we do find something with findObjectOfType, it's just the wrong viz panel?

Copy link
Contributor

Choose a reason for hiding this comment

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

looks like findObject will recursively check all of the children of each parent, so it grabs the viz panel for the logs volume instead

Copy link
Contributor

@gtk-grafana gtk-grafana left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for adding the e2e test as well

@svennergr svennergr merged commit 134bbc1 into main Dec 19, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants