Skip to content
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: multi select width bug #303

Merged
merged 3 commits into from
Feb 3, 2024

Conversation

madassdev
Copy link
Collaborator

@madassdev madassdev commented Feb 1, 2024

Fixed the multi select width bug
Screenshot 2024-02-01 at 08 56 40

Summary by CodeRabbit

  • Refactor
    • Improved visual representation of the select component by conditionally applying classes based on the multiple property.
  • New Features
    • Added the ability to display selected values as a comma-separated list in the select component.
    • Implemented a method to update selected values based on the model value.

@madassdev madassdev requested a review from JhumanJ February 1, 2024 07:58
Copy link
Contributor

coderabbitai bot commented Feb 1, 2024

Walkthrough

The recent enhancements focus on the SelectInput.vue component, introducing a new selectedValues array in the component's data to manage multiple selections efficiently. Additionally, a method updateModelValue has been added to synchronize selectedValues with the model value, improving data consistency. The rendering logic now displays selected values as a comma-separated list, enhancing user experience and clarity.

Changes

File Path Change Summary
client/components/forms/SelectInput.vue Added selectedValues array to data. Added updateModelValue method. Modified rendering logic for displaying selected values.

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?

Share

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>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in 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 generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 5bdc76e and dd4bd4a.
Files selected for processing (1)
  • client/components/forms/components/VSelect.vue (1 hunks)
Files skipped from review due to trivial changes (1)
  • client/components/forms/components/VSelect.vue

Copy link
Owner

@JhumanJ JhumanJ left a 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 looks too good:
image

Instead of truncating each selected element, I think the whole list of element should be truncated. So instead of:
a...,b...,c....
I think it would be best to do:
a,b,c...

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between dd4bd4a and f745da9.
Files selected for processing (1)
  • client/components/forms/SelectInput.vue (4 hunks)
Additional comments: 2
client/components/forms/SelectInput.vue (2)
  • 28-28: The addition of the @update:model-value event handler updateModelValue is a good practice for Vue components, especially for custom input components that need to emit and synchronize their value with the parent component. This ensures that the component remains reactive and updates the parent's state as expected.
  • 124-126: The updateModelValue method correctly updates selectedValues based on the new model value. This is essential for keeping the internal state of the component in sync with its value when used in a form. However, consider adding validation or transformation logic within updateModelValue if the incoming newValues need to be sanitized, validated, or transformed before updating selectedValues. This is particularly important for ensuring data integrity and preventing potential issues with unexpected or malformed data.

Comment on lines +34 to +35
<span class="truncate">
{{ selectedValues.join(', ') }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Displaying selected values as a comma-separated list when multiple is true enhances user experience by providing a clear visual representation of all selected options. However, ensure that this approach aligns with the overall design and UX guidelines of the application. If the list of selected values becomes too long, it might overflow or clutter the UI. Consider implementing a limit to the number of items displayed, with an ellipsis (...) or a "more" indicator for additional selections.

+ <span class="truncate">
+   {{ selectedValues.slice(0, 3).join(', ') + (selectedValues.length > 3 ? ', ...' : '') }}
+ </span>

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
<span class="truncate">
{{ selectedValues.join(', ') }}
<span class="truncate">
{{ selectedValues.slice(0, 3).join(', ') + (selectedValues.length > 3 ? ', ...' : '') }}
</span>

Comment on lines +106 to +107
additionalOptions: [],
selectedValues:[],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The addition of selectedValues array in the component's data is crucial for managing the state of selected options, especially for a multi-select scenario. This approach allows for easier tracking and manipulation of selected options. However, ensure that the initial state of selectedValues is correctly set, particularly if the component is expected to work with pre-selected values passed as props or v-model. You might need to add a watcher or a lifecycle hook (e.g., mounted) to initialize selectedValues based on the initial value of compVal.

+ watch: {
+   compVal(newVal) {
+     this.updateModelValue(newVal);
+   }
+ },

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
additionalOptions: [],
selectedValues:[],
additionalOptions: [],
selectedValues:[],
watch: {
compVal(newVal) {
this.updateModelValue(newVal);
}
},

@madassdev
Copy link
Collaborator Author

I don't think this looks too good: image

Instead of truncating each selected element, I think the whole list of element should be truncated. So instead of: a...,b...,c.... I think it would be best to do: a,b,c...

I don't think this looks too good: image

Instead of truncating each selected element, I think the whole list of element should be truncated. So instead of: a...,b...,c.... I think it would be best to do: a,b,c...

Fixed:
Screenshot 2024-02-02 at 01 08 18

@madassdev madassdev closed this Feb 2, 2024
@madassdev madassdev reopened this Feb 2, 2024
@madassdev madassdev requested a review from JhumanJ February 2, 2024 00:10
@JhumanJ JhumanJ merged commit 8321bd3 into main Feb 3, 2024
4 checks passed
@JhumanJ JhumanJ deleted the 2cc5a-bug-select/multi-select-too-many-options- branch February 3, 2024 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants