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

feat(12618): add tooltips for layers panel buttons on kontur apps #749

Merged

Conversation

Natallia-Harshunova
Copy link
Contributor

@Natallia-Harshunova Natallia-Harshunova commented May 29, 2024

https://kontur.fibery.io/Tasks/My-tasks-3575#Task/Add-tooltips-for-Layers-panel-buttons-on-Kontur-apps-12618

Summary by CodeRabbit

  • New Features

    • Added tooltips for download, edit, erase, hide, and show actions across various layer controls for better user guidance.
    • Integrated LayerActionIcon component for consistent action icons in layer controls.
  • Improvements

    • Enhanced user interaction with localized tooltips for action buttons.
    • Updated edit button functionality to improve user experience.
  • Localization

    • Added internationalized tooltip messages for layer actions in the localization file.

Copy link
Contributor

coderabbitai bot commented May 29, 2024

Walkthrough

The recent updates enhance user interaction by integrating tooltips and a new LayerActionIcon component across various control elements. These changes improve the accessibility and internationalization of actions like download, edit, erase, and visibility toggling. Additionally, the localization file has been updated to include tooltip messages for these actions, ensuring a consistent and user-friendly experience.

Changes

File Path Change Summary
src/components/Layer/DownloadControl/DownloadControl.tsx Updated to use LayerActionIcon for the download button and fetch tooltip message from i18n.
src/components/Layer/EditControl/EditControl.tsx Enhanced with tooltips for edit control, using Tooltip components and i18n for internationalized text. Updated editLayer function to use useCallback.
src/components/Layer/EraseControl/CleanControl.tsx Improved by integrating tooltip for the erase action, using LayerActionIcon and i18n for hint text.
src/components/LayerHideControl/LayerHideControl.tsx Replaced direct rendering of icons with LayerActionIcon for hiding/unhiding layers, including tooltips based on visibility status.
src/core/localization/translations/en/common.json Added tooltips for layer actions like erase, download, edit, hide, and show in the layer_actions object.
src/features/mcda/components/MCDALayerEditor/MCDALayerParameters/MCDALayerParameters.tsx Updated edit button functionality to use LayerActionIcon for improved interaction.

Poem

In the realm of layers, where actions reside,
Icons now sparkle with tooltips as guides.
Download, edit, erase with ease,
Hidden controls now aim to please.
International flair in every click,
A user experience, polished and slick.
🐇✨


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

Language To Recheck Fuzzy Untranslated Total
ar 3 24 101 128
de 2 24 101 127
es 3 24 101 128
id 2 24 101 127
ko 3 24 101 128
uk 0 7 8 15

Copy link

github-actions bot commented May 29, 2024

Bundle size diff

Old size New size Diff
4.9 MB 4.9 MB 1.03 KB (0.02%)

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.

Actionable comments posted: 6

Outside diff range and nitpick comments (3)
src/components/Layer/EraseControl/CleanControl.tsx (1)

Line range hint 18-22: Convert the cleanLayer function to an arrow function for consistency and conciseness.

- const cleanLayer = useCallback(
-   async function () {
-     if (layerActions?.clean) {
-       layerActions.clean();
-     }
-   },
-   [layerActions],
- );
+ const cleanLayer = useCallback(async () => {
+   if (layerActions?.clean) {
+     layerActions.clean();
+   }
+ }, [layerActions]);
src/features/mcda/components/MCDALayerEditor/MCDALayerParameters/MCDALayerParameters.tsx (2)

Line range hint 117-117: Avoid using non-null assertions. Consider handling potential undefined values gracefully.

- const isGoodLeft = layer.sentiment[0] === 'good';
+ const isGoodLeft = layer.sentiment?.[0] === 'good';

- label: layer.sentiment.at(0)!,
+ label: layer.sentiment?.at(0) ?? 'defaultLabel',

Also applies to: 122-122


Line range hint 257-257: Avoid using array indices as keys in React components.

- <div key={`nonDefault${index}`}>{`${v.paramName}: ${v.value}`}</div>
+ <div key={`nonDefault-${v.paramName}`}>{`${v.paramName}: ${v.value}`}</div>

Use a unique identifier related to the item instead of the index.

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 2b66d5c and 15f3b11.
Files ignored due to path filters (1)
  • src/core/localization/translations/en/common.json is excluded by !**/*.json
Files selected for processing (5)
  • src/components/Layer/DownloadControl/DownloadControl.tsx (1 hunks)
  • src/components/Layer/EditControl/EditControl.tsx (2 hunks)
  • src/components/Layer/EraseControl/CleanControl.tsx (2 hunks)
  • src/components/LayerHideControl/LayerHideControl.tsx (2 hunks)
  • src/features/mcda/components/MCDALayerEditor/MCDALayerParameters/MCDALayerParameters.tsx (2 hunks)
Additional Context Used
Biome (13)
src/components/Layer/DownloadControl/DownloadControl.tsx (2)

6-6: Unexpected any. Specify a different type.


14-14: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.

src/components/Layer/EditControl/EditControl.tsx (1)

30-30: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.

src/components/Layer/EraseControl/CleanControl.tsx (2)

18-22: This function expression can be turned into an arrow function.


29-29: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.

src/components/LayerHideControl/LayerHideControl.tsx (2)

21-21: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.


33-33: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.

src/features/mcda/components/MCDALayerEditor/MCDALayerParameters/MCDALayerParameters.tsx (6)

117-117: Forbidden non-null assertion.


122-122: Forbidden non-null assertion.


134-136: This else clause can be omitted because previous branches break early.


228-233: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.


300-303: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.


257-257: Avoid using the index of an array as key property in an element.

Additional comments not posted (5)
src/components/Layer/DownloadControl/DownloadControl.tsx (1)

2-3: Imports for tooltip functionality and localization have been added correctly.

src/components/Layer/EraseControl/CleanControl.tsx (1)

3-4: Imports for tooltip functionality and localization have been added correctly.

src/components/LayerHideControl/LayerHideControl.tsx (1)

2-3: Imports for tooltip functionality and localization have been added correctly.

src/components/Layer/EditControl/EditControl.tsx (1)

3-5: Imports for tooltip functionality, feature flags, and localization have been added correctly.

src/features/mcda/components/MCDALayerEditor/MCDALayerParameters/MCDALayerParameters.tsx (1)

11-15: Imports for tooltip functionality have been added correctly.

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.

Actionable comments posted: 1

Outside diff range and nitpick comments (1)
src/components/Layer/EraseControl/CleanControl.tsx (1)

Line range hint 17-21: Consider refactoring the cleanLayer function to use an arrow function for consistency and conciseness.

-  const cleanLayer = useCallback(
-    async function () {
-      if (layerActions?.clean) {
-        layerActions.clean();
-      }
-    },
-    [layerActions],
-  );
+  const cleanLayer = useCallback(async () => {
+    if (layerActions?.clean) {
+      layerActions.clean();
+    }
+  }, [layerActions]);
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 15f3b11 and d23fc2d.

Files selected for processing (6)
  • src/components/Layer/DownloadControl/DownloadControl.tsx (1 hunks)
  • src/components/Layer/EditControl/EditControl.tsx (2 hunks)
  • src/components/Layer/EraseControl/CleanControl.tsx (2 hunks)
  • src/components/LayerActionButton/LayerActionButton.module.css (1 hunks)
  • src/components/LayerActionButton/LayerActionIcon.tsx (1 hunks)
  • src/components/LayerHideControl/LayerHideControl.tsx (2 hunks)
Files skipped from review as they are similar to previous changes (3)
  • src/components/Layer/DownloadControl/DownloadControl.tsx
  • src/components/Layer/EditControl/EditControl.tsx
  • src/components/LayerHideControl/LayerHideControl.tsx
Additional context used
Biome
src/components/Layer/EraseControl/CleanControl.tsx

[error] 17-21: This function expression can be turned into an arrow function.

src/components/LayerActionButton/LayerActionIcon.tsx

[error] 38-38: The HTML element div is non-interactive. Do not use tabIndex.

Additional comments not posted (2)
src/components/LayerActionButton/LayerActionButton.module.css (1)

1-5: LGTM! The CSS changes are appropriate for enhancing the interactivity of the action buttons.

src/components/LayerActionButton/LayerActionIcon.tsx (1)

1-46: LGTM! The LayerActionIcon component is well-implemented with accessibility and tooltip functionality.

Verification successful

The tabIndex attribute is necessary for making the div focusable, which is crucial for keyboard accessibility. Removing it would hinder the ability to navigate using the keyboard.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the `tabIndex` is necessary for accessibility.

# Test: Check if removing `tabIndex` affects accessibility. Expect: It should not be removed.
echo "Ensure that tabIndex is necessary for keyboard accessibility and should not be removed despite the static analysis error."

Length of output: 252

src/components/Layer/EraseControl/CleanControl.tsx Outdated Show resolved Hide resolved
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.

Actionable comments posted: 0

Outside diff range and nitpick comments (3)
src/components/Layer/EraseControl/CleanControl.tsx (1)

Line range hint 12-16: Consider refactoring the anonymous function to an arrow function for cleaner syntax.

- async function () {
+ () => {
    if (layerActions?.clean) {
      layerActions.clean();
    }
  },
src/components/Layer/useControlElements.tsx (2)

Line range hint 33-33: Ensure all relevant dependencies are specified in the useEffect dependency array to avoid potential bugs.

-  }, [layerState, layerActions, tooltipLayerId]);
+  }, [layerState, layerActions, tooltipLayerId, skipControls]);

Line range hint 38-38: Refactor string concatenation to use template literals for better readability and consistency.

- key={layerState.id + 'hide'}
+ key={`${layerState.id}hide`}
- key={layerState.id + 'edit'}
+ key={`${layerState.id}edit`}
- key={layerState.id + 'clean'}
+ key={`${layerState.id}clean`}
- key={layerState.id + 'download'}
+ key={`${layerState.id}download`}
- key={layerState.id + 'context'}
+ key={`${layerState.id}context`}

Also applies to: 49-49, 58-58, 68-68, 78-78

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d23fc2d and dc8f8e8.

Files selected for processing (2)
  • src/components/Layer/EraseControl/CleanControl.tsx (2 hunks)
  • src/components/Layer/useControlElements.tsx (1 hunks)
Additional context used
Biome
src/components/Layer/EraseControl/CleanControl.tsx

[error] 12-16: This function expression can be turned into an arrow function.

src/components/Layer/useControlElements.tsx

[error] 38-38: Template literals are preferred over string concatenation.


[error] 49-49: Template literals are preferred over string concatenation.


[error] 58-58: Template literals are preferred over string concatenation.


[error] 68-68: Template literals are preferred over string concatenation.


[error] 78-78: Template literals are preferred over string concatenation.


[error] 33-33: This hook does not specify all of its dependencies: skipControls?.skipContextMenu


[error] 33-33: This hook does not specify all of its dependencies: skipControls?.skipLayerInfo


[error] 33-33: This hook does not specify all of its dependencies: skipControls?.skipDownloadControl


[error] 33-33: This hook does not specify all of its dependencies: skipControls?.skipVisibilityControl

Additional comments not posted (2)
src/components/Layer/EraseControl/CleanControl.tsx (2)

3-4: Imports for localization and new tooltip functionality are correctly added.


Line range hint 10-23: The CleanControl component correctly implements the tooltip using LayerActionIcon and ensures proper localization.

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.

Actionable comments posted: 1

Outside diff range and nitpick comments (3)
src/features/mcda/components/MCDALayerEditor/MCDALayerParameters/MCDALayerParameters.tsx (3)

Line range hint 113-113: Avoid using non-null assertions.

Using non-null assertions (!) can lead to runtime errors if the values are actually null. Consider adding null checks or default values.

- layer.sentiment.at(0)!
+ layer.sentiment.at(0) ?? 'default_value'

Also applies to: 118-118


Line range hint 130-132: This else clause can be omitted.

The else clause is redundant here as the previous branches break early. Simplifying this can enhance code readability.

- if (!isNumber(rangeFromNum)) {
-   errorFrom = i18n.t('mcda.layer_editor.errors.range_must_be_a_number');
- }
- if (!isNumber(rangeToNum)) {
-   errorTo = i18n.t('mcda.layer_editor.errors.range_must_be_a_number');
- }
- if (Number(rangeFrom) > Number(rangeTo)) {
-   errorFrom = i18n.t('mcda.layer_editor.errors.range_from_cannot_be_bigger');
- }
- if (!rangeTo) {
-   errorTo = i18n.t('mcda.layer_editor.errors.range_cannot_be_empty');
- }
- if (!rangeFrom) {
-   errorFrom = i18n.t('mcda.layer_editor.errors.range_cannot_be_empty');
- }
+ if (!isNumber(rangeFromNum) || !rangeFrom) {
+   errorFrom = i18n.t('mcda.layer_editor.errors.range_cannot_be_empty');
+ }
+ if (!isNumber(rangeToNum) || !rangeTo) {
+   errorTo = i18n.t('mcda.layer_editor.errors.range_cannot_be_empty');
+ }
+ if (Number(rangeFrom) > Number(rangeTo)) {
+   errorFrom = i18n.t('mcda.layer_editor.errors.range_from_cannot_be_bigger');
+ }

Line range hint 251-251: Avoid using array index as key in React lists.

Using array indices as keys in React can lead to issues with component state and re-rendering. Use unique, stable keys instead.

- <div key={`nonDefault${index}`}>{`${v.paramName}: ${v.value}`}</div>
+ <div key={`nonDefaultValue-${v.paramName}`}>{`${v.paramName}: ${v.value}`}</div>
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between dc8f8e8 and ef63327.

Files selected for processing (2)
  • src/features/mcda/components/MCDALayerEditor/MCDALayerParameters/MCDALayerParameters.module.css (1 hunks)
  • src/features/mcda/components/MCDALayerEditor/MCDALayerParameters/MCDALayerParameters.tsx (2 hunks)
Files skipped from review due to trivial changes (1)
  • src/features/mcda/components/MCDALayerEditor/MCDALayerParameters/MCDALayerParameters.module.css
Additional context used
Biome
src/features/mcda/components/MCDALayerEditor/MCDALayerParameters/MCDALayerParameters.tsx

[error] 113-113: Forbidden non-null assertion.


[error] 118-118: Forbidden non-null assertion.


[error] 130-132: This else clause can be omitted because previous branches break early.


[error] 294-297: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.


[error] 251-251: Avoid using the index of an array as key property in an element.

Additional comments not posted (1)
src/features/mcda/components/MCDALayerEditor/MCDALayerParameters/MCDALayerParameters.tsx (1)

11-11: Added import for LayerActionIcon aligns with the PR's objective to enhance UI components with tooltips.

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.

Actionable comments posted: 1

Outside diff range and nitpick comments (3)
src/components/Layer/EraseControl/CleanControl.tsx (1)

Line range hint 12-16: Consider converting the function expression to an arrow function for improved readability and consistency.

- const cleanLayer = useCallback(
-   async function () {
-     if (layerActions?.clean) {
-       layerActions.clean();
-     }
-   },
-   [layerActions],
- );
+ const cleanLayer = useCallback(async () => {
+   if (layerActions?.clean) {
+     layerActions.clean();
+   }
+ }, [layerActions]);
src/features/mcda/components/MCDALayerEditor/MCDALayerParameters/MCDALayerParameters.tsx (2)

Line range hint 113-113: Consider removing non-null assertions for better safety and simplifying the else clause to enhance code readability.

- setSentiment(layer.sentiment.at(0) === 'good' ? 'good-bad' : 'bad-good');
+ setSentiment(layer.sentiment[0] === 'good' ? 'good-bad' : 'bad-good');

- if (!rangeTo) {
-   errorTo = i18n.t('mcda.layer_editor.errors.range_cannot_be_empty');
- }
+ if (!rangeTo) errorTo = i18n.t('mcda.layer_editor.errors.range_cannot_be_empty');

Also applies to: 118-118, 130-132


Line range hint 251-251: Use unique keys for list items to prevent potential issues with re-rendering. Also, ensure keyboard accessibility by adding onKeyUp events.

- <div key={`nonDefault${index}`}>{`${v.paramName}: ${v.value}`}</div>
+ <div key={`nonDefault-${v.paramName}`}>{`${v.paramName}: ${v.value}`}</div>

- <div
+ <div onKeyUp={handleKeyUpReset}

Also applies to: 294-297

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ef63327 and 88a62be.

Files selected for processing (7)
  • src/components/Layer/DownloadControl/DownloadControl.tsx (1 hunks)
  • src/components/Layer/EditControl/EditControl.tsx (2 hunks)
  • src/components/Layer/EraseControl/CleanControl.tsx (2 hunks)
  • src/components/LayerActionIcon/LayerActionIcon.module.css (1 hunks)
  • src/components/LayerActionIcon/LayerActionIcon.tsx (1 hunks)
  • src/components/LayerHideControl/LayerHideControl.tsx (2 hunks)
  • src/features/mcda/components/MCDALayerEditor/MCDALayerParameters/MCDALayerParameters.tsx (2 hunks)
Files skipped from review due to trivial changes (1)
  • src/components/LayerActionIcon/LayerActionIcon.module.css
Files skipped from review as they are similar to previous changes (2)
  • src/components/Layer/DownloadControl/DownloadControl.tsx
  • src/components/LayerHideControl/LayerHideControl.tsx
Additional context used
Biome
src/components/Layer/EraseControl/CleanControl.tsx

[error] 12-16: This function expression can be turned into an arrow function.

src/components/LayerActionIcon/LayerActionIcon.tsx

[error] 38-38: The HTML element div is non-interactive. Do not use tabIndex.

src/features/mcda/components/MCDALayerEditor/MCDALayerParameters/MCDALayerParameters.tsx

[error] 113-113: Forbidden non-null assertion.


[error] 118-118: Forbidden non-null assertion.


[error] 130-132: This else clause can be omitted because previous branches break early.


[error] 294-297: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.


[error] 251-251: Avoid using the index of an array as key property in an element.

Additional comments not posted (8)
src/components/Layer/EraseControl/CleanControl.tsx (2)

3-4: Imports and function signature changes are appropriate and align with the PR objectives.

Also applies to: 10-10


21-23: The use of LayerActionIcon with tooltips in JSX is correctly implemented and enhances user interaction.

src/components/Layer/EditControl/EditControl.tsx (3)

3-6: Imports for localization and LayerActionIcon are correctly added to enhance functionality.


21-27: The dynamic import within the editLayer function is a good use of code splitting, enhancing performance by loading code only when needed.


30-32: The use of LayerActionIcon with tooltips in JSX is correctly implemented and enhances user interaction.

src/components/LayerActionIcon/LayerActionIcon.tsx (2)

1-11: Imports and interface definition in LayerActionIcon are correctly implemented, supporting reusability and extensibility.


27-45: The implementation of tooltips and triggers in JSX is correctly done, enhancing accessibility and user interaction.

Tools
Biome

[error] 38-38: The HTML element div is non-interactive. Do not use tabIndex.

src/features/mcda/components/MCDALayerEditor/MCDALayerParameters/MCDALayerParameters.tsx (1)

11-11: Import of LayerActionIcon is correctly added to enhance functionality.

@albaranau albaranau merged commit 5b37ac5 into main Jun 3, 2024
7 checks passed
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.

Actionable comments posted: 1

Outside diff range comments (4)
src/components/Layer/EraseControl/CleanControl.tsx (1)

Line range hint 10-23: LGTM! The integration of LayerActionIcon with localization support enhances the tooltip functionality.

Consider converting the cleanLayer function expression to an arrow function for consistency and potentially better performance in future React versions.

- const cleanLayer = useCallback(
-   async function () {
-     if (layerActions?.clean) {
-       layerActions.clean();
-     }
-   },
-   [layerActions],
- );
+ const cleanLayer = useCallback(async () => {
+   if (layerActions?.clean) {
+     layerActions.clean();
+   }
+ }, [layerActions]);
src/components/Layer/useControlElements.tsx (1)

Line range hint 33-33: Ensure all dependencies are specified in the useEffect hook to avoid potential bugs due to missing updates.

- }, [layerState, layerActions, tooltipLayerId]);
+ }, [layerState, layerActions, tooltipLayerId, skipControls]);
Tools
Biome

[error] 58-58: Template literals are preferred over string concatenation.

src/features/mcda/components/MCDALayerEditor/MCDALayerParameters/MCDALayerParameters.tsx (2)

Line range hint 124-124: Avoid using non-null assertions as they can lead to runtime errors if assumptions about non-nullability prove incorrect.

- const isGoodLeft = layer.sentiment[0] === 'good';
- return {
-   left: {
-     label: layer.sentiment.at(0)!, // Sentiments name needed instead of id
-     color: isGoodLeft ? sentimentColors.good : sentimentColors.bad,
-     value: String(layer.range.at(0)),
-   },
-   right: {
-     label: layer.sentiment.at(1)!,
-     color: isGoodLeft ? sentimentColors.bad : sentimentColors.good,
-     value: String(layer.range.at(1)),
-   },
- };
+ const isGoodLeft = layer.sentiment[0] === 'good';
+ const leftLabel = layer.sentiment.at(0);
+ const rightLabel = layer.sentiment.at(1);
+ if (!leftLabel || !rightLabel) {
+   throw new Error('Sentiment labels are required.');
+ }
+ return {
+   left: {
+     label: leftLabel,
+     color: isGoodLeft ? sentimentColors.good : sentimentColors.bad,
+     value: String(layer.range.at(0)),
+   },
+   right: {
+     label: rightLabel,
+     color: isGoodLeft ? sentimentColors.bad : sentimentColors.good,
+     value: String(layer.range.at(1)),
+   },
+ };

Also applies to: 129-129


Line range hint 307-310: Ensure keyboard accessibility for all interactive elements to enhance usability for all users.

+ onKeyUp={handleKeyUpEdit}
Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 88a62be and 070457b.

Files selected for processing (7)
  • src/components/Layer/DownloadControl/DownloadControl.tsx (1 hunks)
  • src/components/Layer/EditControl/EditControl.tsx (2 hunks)
  • src/components/Layer/EraseControl/CleanControl.tsx (2 hunks)
  • src/components/Layer/useControlElements.tsx (1 hunks)
  • src/components/LayerHideControl/LayerHideControl.tsx (2 hunks)
  • src/core/localization/translations/en/common.json (1 hunks)
  • src/features/mcda/components/MCDALayerEditor/MCDALayerParameters/MCDALayerParameters.tsx (2 hunks)
Additional context used
Biome
src/components/Layer/EraseControl/CleanControl.tsx

[error] 12-16: This function expression can be turned into an arrow function.

src/components/Layer/useControlElements.tsx

[error] 38-38: Template literals are preferred over string concatenation.


[error] 49-49: Template literals are preferred over string concatenation.


[error] 58-58: Template literals are preferred over string concatenation.


[error] 68-68: Template literals are preferred over string concatenation.


[error] 78-78: Template literals are preferred over string concatenation.


[error] 33-33: This hook does not specify all of its dependencies: skipControls?.skipContextMenu


[error] 33-33: This hook does not specify all of its dependencies: skipControls?.skipLayerInfo


[error] 33-33: This hook does not specify all of its dependencies: skipControls?.skipDownloadControl


[error] 33-33: This hook does not specify all of its dependencies: skipControls?.skipVisibilityControl

src/features/mcda/components/MCDALayerEditor/MCDALayerParameters/MCDALayerParameters.tsx

[error] 124-124: Forbidden non-null assertion.


[error] 129-129: Forbidden non-null assertion.


[error] 141-143: This else clause can be omitted because previous branches break early.


[error] 307-310: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.


[error] 264-264: Avoid using the index of an array as key property in an element.

Additional comments not posted (4)
src/components/Layer/DownloadControl/DownloadControl.tsx (1)

5-12: LGTM! The integration of LayerActionIcon with localization support enhances the tooltip functionality.

src/components/LayerHideControl/LayerHideControl.tsx (1)

18-27: LGTM! The integration of LayerActionIcon with localization support enhances the tooltip functionality for both hiding and showing layers.

src/components/Layer/EditControl/EditControl.tsx (1)

30-32: LGTM! The integration of LayerActionIcon with localization support enhances the tooltip functionality for the edit action.

src/core/localization/translations/en/common.json (1)

34-42: The added tooltips for layer actions are correctly implemented and localized.

src/components/Layer/useControlElements.tsx Show resolved Hide resolved
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.

4 participants