-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 grid size picker size #21161
Fix grid size picker size #21161
Conversation
WalkthroughWalkthroughThe change involves renaming a component within the Changes
Recent review detailsConfiguration used: CodeRabbit UI Files selected for processing (1)
Additional context usedBiome
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 as PR comments)
Additionally, you can add CodeRabbit Configration 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: 1
Outside diff range comments (5)
src/panels/lovelace/editor/card-editor/hui-card-layout-editor.ts (5)
Line range hint
202-202
: Replace non-null assertion with optional chaining.Using non-null assertions can lead to runtime errors if the object is null or undefined. Replace it with optional chaining to ensure that your code is more robust and error-resistant.
- if (newConfig.layout_options!.grid_columns === undefined) { + if (newConfig.layout_options?.grid_columns === undefined) {
Line range hint
203-203
: Avoid using the delete operator; consider setting properties to undefined.Using the
delete
operator can lead to performance issues due to changes in the object's hidden class in JavaScript engines. Consider setting the property toundefined
instead, which keeps the hidden class consistent and avoids performance penalties.- delete newConfig.layout_options!.grid_columns; + newConfig.layout_options!.grid_columns = undefined; - delete newConfig.layout_options!.grid_rows; + newConfig.layout_options!.grid_rows = undefined;Also applies to: 206-206
Line range hint
206-206
: Consider checking for empty properties more robustly.When checking if
layout_options
is empty, consider using a more robust method to handle cases where other properties might still exist. You can useObject.keys()
and check if its length is zero.- if (Object.keys(newConfig.layout_options!).length === 0) { + if (Object.keys(newConfig.layout_options || {}).length === 0) {
Line range hint
208-208
: Replace non-null assertion with optional chaining inlayout_options
check.To prevent potential runtime errors from non-null assertions, use optional chaining when accessing properties on
layout_options
.- if (Object.keys(newConfig.layout_options!).length === 0) { + if (Object.keys(newConfig.layout_options || {}).length === 0) {
Line range hint
209-209
: Avoid using the delete operator onlayout_options
; set to undefined instead.Similar to previous comments, consider setting
layout_options
toundefined
instead of using thedelete
operator to avoid performance issues.- delete newConfig.layout_options; + newConfig.layout_options = undefined;
@@ -246,7 +246,7 @@ export class HuiCardLayoutEditor extends LitElement { | |||
opacity: 0.5; | |||
pointer-events: none; | |||
} | |||
ha-grid-size-editor { | |||
ha-grid-size-picker { |
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.
Consider optimizing the style block for better performance and maintainability.
The ha-grid-size-picker
and ha-yaml-editor
are styled directly within this component. Consider moving these styles to their respective components if they are not overridden elsewhere. This would enhance maintainability and ensure that styles are managed more locally.
Proposed change
Style was obsolete after renaming component
Type of change
Example configuration
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed:
Summary by CodeRabbit
Grid Size Editor
toGrid Size Picker
in the card layout editor for improved clarity and consistency.