frontend
frontend copied to clipboard
Enhance Todo card item textfield with combobox
Proposed change
Enhance the todo list new item box to autocomplete existing checked items. I thought this was a nice usability improvement, though the code ended up being way more difficult to get exactly right than I initially anticipated, so I can't say for sure if the feature is worth the additional code complexity.
Type of change
- [ ] Dependency upgrade
- [ ] Bugfix (non-breaking change which fixes an issue)
- [x] New feature (thank you!)
- [ ] Breaking change (fix/feature causing existing functionality to break)
- [ ] Code quality improvements to existing code or addition of tests
Example configuration
Additional information
- This PR fixes or closes issue: fixes #
- This PR is related to issue or discussion:
- Link to documentation pull request:
Checklist
- [x] The code change is tested and works locally.
- [x] There is no commented out code in this PR.
- [ ] Tests have been added to verify that the new code works.
If user exposed functionality or configuration variables are added/changed:
- [ ] Documentation added/updated for www.home-assistant.io
Summary by CodeRabbit
-
New Features
- Added a
noButtonproperty to the combo box component, allowing users to hide the button if desired. - Enhanced the todo list card with a new combo box for item input, improving the user experience with better filtering and selection options.
- Added a
-
Improvements
- Updated event handling and rendering logic in the todo list card for more responsive interactions and better performance.
[!IMPORTANT]
Review skipped
Auto reviews are disabled on this repository.
Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.
Walkthrough
The recent changes enhance the ha-combo-box component by introducing a noButton property to control button visibility and updating its rendering logic. Additionally, the hui-todo-list-card has been refactored to integrate ha-combo-box for improved item management, incorporating new states and event handling methods to support filtering and value changes.
Changes
| File Path | Change Summary |
|---|---|
src/components/ha-combo-box.ts |
Added nothing import, introduced noButton property, and updated rendering logic accordingly. |
src/panels/lovelace/cards/... |
Integrated ha-combo-box, added new states and methods for filtering and value handling. |
Sequence Diagram(s) (Beta)
sequenceDiagram
participant User
participant HaComboBox
participant HuiTodoListCard
User->>+HuiTodoListCard: Add new item
HuiTodoListCard->>+HaComboBox: Open combo box
HaComboBox->>-User: Display options
User->>+HaComboBox: Select or input value
HaComboBox->>-HuiTodoListCard: Return selected/input value
HuiTodoListCard->>HuiTodoListCard: Update _comboValue state
HuiTodoListCard->>HuiTodoListCard: Render new item in todo list
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?
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
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)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
I like it! What do you think @Madelena? As you made the original design.
I like it! What do you think @Madelena? As you made the original design.
I like it, too. What does it look like if one of the search results is incomplete? Would it show an unchecked checkbox?
I like it, too. What does it look like if one of the search results is incomplete? Would it show an unchecked checkbox?
IIRC I think incomplete items were not autocompleted, so you wouldn't see them.
The thinking was since this was the "add item" field, it wouldn't make sense to be adding items that already existed in the list.
But that could be changed if desired.
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks :+1:
The thinking was since this was the "add item" field, it wouldn't make sense to be adding items that already existed in the list.
But that could be changed if desired.
That makes totally sense, why would you add the same todo twice? I would keep it like this :+1:
If we want to keep default behavior is clearable, should the default property be unclearable = false ?
IIRC can't have a boolean attribute with default of true, since you can't change it via attribute.
Plus icon button is not clickable when combo box is visible
I thought all combo box always steal the focus from the entire screen, and click once closes it? I'm not sure if that should be changed, or even how to do so.
That makes totally sense, why would you add the same todo twice? I would keep it like this 👍
It could be that if you clicked on an unchecked item in the combo, it could mark it as complete. So it becomes more of a "search" box than strictly for adding. Could be useful if you had a shopping list with hundreds of items or something.
But perhaps that is out of scope for this PR.
Sorry I think I'm going to drop this. Code feels too hacky and I don't think I'm experienced enough to figure out the correct way to implement this.