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

General: Fix color selector placement of exercise categories & dropdown activation #8874

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

asliayk
Copy link
Contributor

@asliayk asliayk commented Jun 25, 2024

Checklist

General

Client

Motivation and Context

While adding categories to an exercise there are two bugs:

  • Color Selector Misalignment: The color selector is not horizontally aligned with new categories as they are added. It needs adjustment to ensure it consistently matches the horizontal position of each new category. (Related issue: General: Improve category selection styling #7515)
  • Dropdown Activation Inconsistency: The autocomplete dropdown menu opens unnecessarily when a new category is created and added, even though there are already two categories, which is the maximum allowed. This behavior does not occur when adding a pre-existing category, indicating that the dropdown's activation logic needs adjustment. (Related issue: Autocomplete dropdown opens unnecessarily when adding new category #8873)

Description

  • The color selector now aligns horizontally with each new category.
  • The autocomplete dropdown menu no longer opens automatically upon adding a newly created category (not pre-existing). It activates only when the user clicks on the input area, and it refrains from opening once the maximum number of categories has been reached.

Steps for Testing

Prerequisites:

  • 1 Instructor
  1. Log in to Artemis
  2. Navigate to course management page and click on exercises button of a course
  3. Click on any 'Create ... Exercise' button.
  4. In categories section, add one category. Then create a new category and add it as the second category. See that dropdown does not open after adding it.
  5. Click on the second category to change its color. See that the color selector is now closer to the second category. (horizontally aligned)

Testserver States

Note

These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Click on the badges to get to the test servers.







Review Progress

Performance Review

  • I (as a reviewer) confirm that the client changes (in particular related to REST calls and UI responsiveness) are implemented with a very good performance
  • I (as a reviewer) confirm that the server changes (in particular related to database calls) are implemented with a very good performance

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Exam Mode Test

  • Test 1
  • Test 2

Test Coverage

Screenshots

image

Summary by CodeRabbit

  • New Features
    • Improved autocomplete functionality in the category selector component for a more seamless user experience.
    • Enhanced event handling in the color selector component, allowing for more accurate positioning based on user interactions.

@asliayk asliayk added client Pull requests that update TypeScript code. (Added Automatically!) small bugfix labels Jun 25, 2024
@asliayk asliayk self-assigned this Jun 25, 2024
@asliayk asliayk requested a review from a team as a code owner June 25, 2024 22:17
Copy link

coderabbitai bot commented Jun 25, 2024

Walkthrough

The changes introduce new functionality and event handling updates to two components, CategorySelectorComponent and ColorSelectorComponent. In CategorySelectorComponent, an autocomplete mechanism is enhanced with a new import and method to close the panel programmatically. In ColorSelectorComponent, the event handling logic is simplified by directly referencing the clicked element to manage the position of the color selector.

Changes

File Path Summary
src/main/webapp/.../category-selector/category-selector.component.ts Introduced MatAutocompleteTrigger import, updated @ViewChild declaration, included panel close method.
src/main/webapp/.../color-selector/color-selector.component.ts Simplified event handling logic by directly referencing the clicked element to determine positioning.

Recent review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 57161b3 and 6b123b3.

Files selected for processing (2)
  • src/main/webapp/app/shared/category-selector/category-selector.component.ts (3 hunks)
  • src/main/webapp/app/shared/color-selector/color-selector.component.ts (1 hunks)
Additional context used
Path-based instructions (2)
src/main/webapp/app/shared/color-selector/color-selector.component.ts (1)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

src/main/webapp/app/shared/category-selector/category-selector.component.ts (1)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

Biome
src/main/webapp/app/shared/category-selector/category-selector.component.ts

[error] 65-65: Forbidden non-null assertion. (lint/style/noNonNullAssertion)

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator


[error] 72-72: Forbidden non-null assertion. (lint/style/noNonNullAssertion)

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator


[error] 78-78: Forbidden non-null assertion. (lint/style/noNonNullAssertion)

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator


[error] 78-78: Forbidden non-null assertion. (lint/style/noNonNullAssertion)

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator


[error] 131-131: Forbidden non-null assertion. (lint/style/noNonNullAssertion)

Unsafe fix: Replace with optional chain operator ?. This operator includes runtime checks, so it is safer than the compile-only non-null assertion operator

Additional comments not posted (4)
src/main/webapp/app/shared/color-selector/color-selector.component.ts (1)

80-81: Refactor suggestion for element selection logic.

The updated logic now directly uses the event.target to determine the clicked element, which simplifies the selector logic and makes it more robust by avoiding reliance on specific parent class names.

src/main/webapp/app/shared/category-selector/category-selector.component.ts (3)

10-10: Addition of MatAutocompleteTrigger import.

The import of MatAutocompleteTrigger is necessary for managing the autocomplete functionality programmatically, particularly for closing the panel when conditions like maximum category count are met.


37-37: Usage of @ViewChild for MatAutocompleteTrigger.

This addition allows direct access to the autocomplete trigger in your TypeScript code, which is essential for controlling the dropdown behavior dynamically based on the application's state.


133-133: Explicit panel closure after adding a category.

Closing the autocomplete panel programmatically after adding a category is a crucial UX improvement, especially when the maximum number of categories has been reached. This prevents the dropdown from appearing unnecessarily, aligning with the PR's objectives.


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 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 @coderabbitai in 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 @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 and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @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.
  • 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.

Copy link

@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.

Actionable comments posted: 0

Outside diff range comments (1)
src/main/webapp/app/shared/category-selector/category-selector.component.ts (1)

Line range hint 65-65: Resolve non-null assertion warnings.

The use of non-null assertions (!) can lead to runtime errors if not handled carefully. Consider replacing them with optional chaining (?) to ensure safety.

- event.chipInput!.clear();
+ event.chipInput?.clear();

- this.categoryCtrl.setValue(null);
+ this.categoryCtrl.setValue(null); // Assuming this is the line you intended to modify, please verify.

Also applies to: 72-72, 78-78, 78-78, 131-131

Copy link
Contributor

@egekurt123 egekurt123 left a comment

Choose a reason for hiding this comment

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

Works as expected on TS5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix client Pull requests that update TypeScript code. (Added Automatically!) ready for review small
Projects
Status: Work In Progress
2 participants