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
feat: Find a parent component with a given type #14002
Conversation
Personally I don't like that much the idea of traversing the tree and directly interact with an ancestor component, but I can get the points expressed in the related issue. Some cosiderations on the proposed implementation:
|
ComponentUtil feels like a set of internal helpers to me and it is not documented at all (other than JavaDocs), so I think far less developers would find it from there. Renamed. Much better! Also make protected. This is bit controversial. I guess most often one uses that from component, so protected should be fine, but somehow I have a feeling that someday I find my self opening that method directly as public in some Vaadin view 🤷♂️ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would still move the implementation to ComponentUtil
and then have the method in Component
that delegates to it.
But it is up to you.
Other than that, LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would still move the implementation to ComponentUtil and then have the method in Component that delegates to it.
This sounds better for me as well.
By the way, I don't get the idea why you made it protected
? The use case is to get the layout/menu or other high level component to modify it somehow. This method is invoked for some child component, so should the application actually extend the component to use this API, since is a protected, not public.
I would make it public, but transfer the implementation to the utils.
I suggested to make the method protected
But it seems that I'm the only one that do not see the usage from outside a component, so let it be public 😄 |
Reverted back to public. Are we sure about having the actual implementation delegated to ComponentUtil 🤔 Then we would have basically the same method in two places. Would somebody want to have it in ComponentUtil if it is available as a public instance method 🤔 |
Well, I would say it can be reused when moved to utils. But it can also be reused if placed to component directly. |
👌 I'll write some basic unit test for this and convert to actual PR. |
@mshabarov I'm ready with this! |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
This ticket/PR has been released with Vaadin 23.2.0. |
Description
Add a helper method to seek the parent component of given type from the component tree.
Fixes #13984
Type of change
Checklist
Additional for
Feature
type of change