-
Notifications
You must be signed in to change notification settings - Fork 1
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: don't render empty label #24
Conversation
WalkthroughThe changes made in the Changes
Assessment against linked issues
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (2)
src/main/resources/META-INF/resources/frontend/src/fc-badge-list.ts (2)
238-243
: LGTM:update
method implementationThe
update
method is well-implemented to handle changes to thelabel
property. It correctly toggles thehas-label
attribute based on the presence of a label.Consider using a more strict comparison for better clarity:
- this.toggleAttribute('has-label', this.label != null); + this.toggleAttribute('has-label', this.label !== null && this.label !== '');This change would ensure that empty strings are also treated as absent labels, which might be desirable for consistency.
Line range hint
70-70
: Consider adjusting thelabel
property default valueThe
label
property is correctly declared, but its default value of an empty string might lead to unexpected behavior. An empty string is truthy in JavaScript, which means thehas-label
attribute would be set even when no label is explicitly provided.Consider changing the default value to
null
orundefined
:- @property() - label : '' + @property() + label: string | null = nullThis change would ensure that the
has-label
attribute is only set when a non-empty label is explicitly provided, aligning better with the PR's objective.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- src/main/resources/META-INF/resources/frontend/src/fc-badge-list.ts (2 hunks)
🔇 Additional comments (2)
src/main/resources/META-INF/resources/frontend/src/fc-badge-list.ts (2)
88-91
: LGTM: CSS changes for label visibilityThe new CSS rule effectively hides the label when the
has-label
attribute is not present. This change aligns well with the PR objective of not rendering an empty label, improving the component's visual consistency.
Line range hint
1-244
: Overall implementation reviewThe changes successfully address the issue of rendering empty labels in the BadgeList component. The implementation is clean, well-structured, and follows best practices for LitElement components. The new CSS rule and the
update
method work together to control the visibility of the label based on its presence.To ensure the changes work as expected across the codebase, please run the following verification script:
This script will help identify any potential issues with the usage of the BadgeList component across the codebase, ensuring that the new changes are compatible with existing implementations.
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.
Review commit message per https://github.com/FlowingCode/DevelopmentConventions/blob/main/conventional-commits.md#3-subject
@javier-godoy updated with new commit message |
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.
LGTM
Close #23
Adds "has-label" attribute to control the rendering of the label.
This can be tested in ReadOnlyBinderDemo in which the BadgeList component adds a label and, inspecting the DOM will show this component has the "has-label" attribute and so the label is being rendered. The opposite can be tested in the other two demo views in which the BadgeList components are not expected to render a label, so no "has-label" attribute is present and no empty label is present either.
Summary by CodeRabbit
New Features
Bug Fixes