Skip to content

[Discover][Embeddable] Search embeddable to keep all SO fields#204651

Closed
kowalczyk-krzysztof wants to merge 1 commit intoelastic:mainfrom
kowalczyk-krzysztof:fix/search-embedabble-so-fields
Closed

[Discover][Embeddable] Search embeddable to keep all SO fields#204651
kowalczyk-krzysztof wants to merge 1 commit intoelastic:mainfrom
kowalczyk-krzysztof:fix/search-embedabble-so-fields

Conversation

@kowalczyk-krzysztof
Copy link
Copy Markdown
Member

Summary

This PR makes it so unlinking a search panel from the library retains all SO attributes.
Closes: #196732

@kowalczyk-krzysztof kowalczyk-krzysztof self-assigned this Dec 17, 2024
@elasticmachine
Copy link
Copy Markdown
Contributor

🤖 Jobs for this PR can be triggered through checkboxes. 🚧

ℹ️ To trigger the CI, please tick the checkbox below 👇

  • Click to trigger kibana-pull-request for this PR!
  • Click to trigger kibana-deploy-project-from-pr for this PR!

@kowalczyk-krzysztof
Copy link
Copy Markdown
Member Author

@davismcphee
Is the goal of the linked issue to retain ALL saved object state or some specific fields (if so, which ones?)

@timductive
Copy link
Copy Markdown
Member

@kertal can you answer this while davis is out?

@kertal
Copy link
Copy Markdown
Member

kertal commented Dec 19, 2024

sure, so @davismcphee wrote

When I unlink a search panel from the library in main, it keeps all of the SO properties and passes them to Discover when clicking the edit dropdown link. In this PR it looks like some of the properties are dropped when unlinking, so clicking edit doesn't carry over some state like the breakdown field. I feel like it might be best to keep all of the state if possible in case we decide to use it in the embeddable in the future.

Yes, I think we should keep them all

Comment on lines +100 to 102
const breakdownField$ = new BehaviorSubject<string | undefined>(initialState.breakdownField);

/**
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

hmm , I'm not familar with the embeddable code here, but if we want to keep those fields, do we need to introduce observables for all of those, even if they don't change? @jughosta , do you know ? thx

Copy link
Copy Markdown
Member Author

@kowalczyk-krzysztof kowalczyk-krzysztof Dec 19, 2024

Choose a reason for hiding this comment

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

I asked @Heenawter about this, and apparently this is the way to go and this is where the question about whether we really want ALL of the SO properties comes from.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yes, that's a good question, because if this is the way to go, we would need to change this part of the code every time new properties are introduced. Which doesn not happen too often, but still ... I'd prefer a way that would take care of this automatically, @Heenawter is there an alternative to his ? thx!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@kertal I guess I'm a bit confused what the goal is here. When you unlink a saved search, if that saved object has state that doesn't need to be used for the embeddable, why would we want to keep track of it in the embeddable? If you want to track a piece of state, the comparators for an embeddable require an observable because it's assuming that most state is "editable" - if it's state that doesn't change and isn't required for the embeddable to function, do you really need to track it? Why keep state around that you don't need? 🤷

cc @nreese @ThomThomson

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not exactly sure why you'd want to track all of the saved object state when the panel is no longer linked. In #203662 I also added a rawSavedObjectAttributes which tracks the attributes taken directly from the saved object. So if you really need to retain that information I'd recommend storing it there.

On the other hand, if there isn't a user-facing reason for this change is it really worth doing? I'd let the data discovery team weigh in on that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

let's pause until @davismcphee is back from PTO in the new year, who originally requested this change

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey all, I'm back from PTO and catching up on this now. I originally raised this in the refactor review partly because it was a change from what existed in main, and because there are scenarios where it may be unexpected.

A Discover session (saved search) contains more state than what we actually use in the embeddable panel, e.g. breakdown field and Lens vis config. If I create a Discover session with a custom Lens vis and add it as a dashboard panel, clicking "Open in Discover" will include my custom vis. This could be useful for users who want to kick off an investigation from a dashboard to a fully configured Discover view (especially as Discover sessions evolve for One Discover). But after the refactor, unlinking a Discover session panel removes all but the panel state, so the custom vis is gone when navigating to Discover. We don't have save and return support in Discover currently, but the same situation would apply there too.

So it's mainly a question of expectations. As a user, I would personally expect all of my Discover state to be preserved when unlinking or save-and-returning to support these cases (especially if rawSavedObjectAttributes makes this easy), but I don't feel super strongly about it. If others disagree, we could leave it as is and revisit if we receive feedback or it impacts later work.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't have anything of value to add to this discussion but I would appreciate if some kind of decision could be made on how to proceed with this issue. This started as a papercut but I'm not sure if that still would be the case now and if I should be involved in this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for working on this and bearing with us @kowalczyk-krzysztof. The team is all back from holidays now so I've added an agenda item for us to discuss this in our team sync next Monday, and we'll followup with the decision. If we decide we need something more complex than what you have here, we can take over the remainder of the work.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@kowalczyk-krzysztof Looks like you noticed and closed already, but for future reference we discussed this in our team sync today and decided to leave this as a known issue for now unless a user raises it again or it blocks later work. Apologies that you worked on this only to have us close it, but we appreciate the effort regardless!

@kowalczyk-krzysztof kowalczyk-krzysztof deleted the fix/search-embedabble-so-fields branch August 31, 2025 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Discover][Embeddable] Unlinking a search panel from the library should retain all SO attributes

7 participants