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
Add HasHelper interface #8922
Add HasHelper interface #8922
Conversation
|
||
/** | ||
* <p> | ||
* String used for the helper text. |
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.
One might wonder, "what is helper text" as it is not that universal concept (yet?) compared to e.g. placeholder. At least could be unfamiliar for Java developers. So I think it would be good to add a clarification on "how/when it might be shown on the component"
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.
And same for setHelperComponent
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.
Added text describing the feature more for both setters.
default void setHelperComponent(Component component) { | ||
getElement().getChildren() | ||
.filter(child -> "helper".equals(child.getAttribute("slot"))) | ||
.collect(Collectors.toList()) |
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.
Unnecessary collecting to a list since it seems like there can only ever be one child with the slot=helper, so could go with findAny().ifPresent(...)
instead
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.
Changed.
Optional<Element> element = getElement().getChildren() | ||
.filter(child -> "helper".equals(child.getAttribute("slot"))) | ||
.findFirst(); | ||
if (element.isPresent()) { |
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 don't think this is necessary for readability as it adds more lines, could just use mapping to the Stream with map(Element::get)
before findFirst()
and then return component.orElse(null);
.
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 changed as suggested, but then findFirst()
returns an Optional<Optional<Component>>
object, so I had to add a .orElse(Optional.empty())
.
* Add HasHelper interface (#8532)
PR to master (5.0) open too. |
* Add HasHelper interface (#8532)
On this PR:
Fix #8871