Skip to content

Comments

feat(search): 22291 select area when location chosen#1194

Merged
Komzpa merged 11 commits intomainfrom
codex/update-location-selection-behavior
Aug 27, 2025
Merged

feat(search): 22291 select area when location chosen#1194
Komzpa merged 11 commits intomainfrom
codex/update-location-selection-behavior

Conversation

@Komzpa
Copy link
Member

@Komzpa Komzpa commented Jul 30, 2025

Summary

  • select searched location as focused geometry
  • highlight search results on hover

Fibery ticket: 22291


https://chatgpt.com/codex/tasks/task_b_688a6fe48090832691cc10f832b5b872

Summary by CodeRabbit

  • New Features

    • Added interactive geometry highlighting when hovering over search results, displaying highlighted areas on the map.
    • Introduced a dedicated map layer for displaying highlighted search geometries with a distinct color.
    • Selecting a search result with geometry now focuses the map and highlights the selected area.
  • Documentation

    • Added documentation explaining the search feature, including geometry highlighting and involved components.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 30, 2025

Walkthrough

A search result geometry highlighting feature is introduced. New atoms and constants manage highlighted geometries and layer settings. The SearchBar component now highlights geometries on hover and clears them on unmount or menu close. A new initialization function registers a highlight layer, and related documentation and renderer class are added. Location selection now focuses on item geometry. Tests for the new atom, initialization function, location selection logic, and related actions are included.

Changes

Cohort / File(s) Change Summary
Highlighted Geometry Atom
src/features/search/atoms/highlightedGeometry.ts
Adds searchHighlightedGeometryAtom, an atom holding either a GeoJSON FeatureCollection or Feature, initialized empty.
Search Bar Highlight Integration
src/features/search/componets/SearchBar/SearchBar.tsx
Integrates geometry highlighting: sets highlighted geometry on hover for location items, clears on mouse leave, unmount, and menu close, using the new atom.
Highlight Layer Constants
src/features/search/constants.ts
Adds exported constants: SEARCH_HIGHLIGHT_LAYER_ID, SEARCH_HIGHLIGHT_COLOR, and EMPTY_HIGHLIGHT for highlight layer configuration and default empty geometry.
Search Layer Initialization
src/features/search/initSearchHighlightLayer.ts
Introduces initSearchHighlightLayer to initialize and register a reactive highlight layer, subscribing to geometry atom changes and using a custom renderer.
Highlight Renderer
src/features/search/renderers/SearchHighlightRenderer.ts
Adds SearchHighlightRenderer class, extending BoundarySelectorRenderer without modification.
Search Entry Point Integration
src/features/search/index.tsx
Imports and invokes initSearchHighlightLayer in a useEffect on mount to ensure highlight layer is set up when the Search component loads.
Location Selection Focus
src/features/search/searchLocationAtoms.ts
Enhances selectLocationItemAction to set focused geometry and invoke focusOnGeometry when a selected item has geometry, in addition to updating the map bounding box.
Search Selection Highlight Reset
src/features/search/searchAtoms.ts
Updates itemSelectAction to clear highlighted geometry by setting it to empty after item selection.
Feature Documentation
src/features/search/readme.md
Adds documentation describing the search feature's geometry highlighting, involved components, and user interaction details.
Highlighted Geometry Atom Tests
src/features/search/tests/highlightedAtom.test.ts
Adds tests for searchHighlightedGeometryAtom verifying initial empty state and update behavior with GeoJSON features.
Search Highlight Layer Initialization Tests
src/features/search/tests/initSearchHighlightLayer.test.ts
Adds tests for initSearchHighlightLayer verifying renderer instantiation, subscription, and cleanup behavior with mocked dependencies (currently skipped).
Location Selection Action Tests
src/features/search/tests/searchLocationAtoms.test.ts
Adds tests for selectLocationItemAction verifying map bbox setting, focused geometry updates, and focus behavior based on presence of geometry in selected items.
Search Atoms Selection Tests
src/features/search/tests/searchAtoms.test.ts
Adds tests for itemSelectAction verifying that highlighted geometry atom is cleared upon item selection.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SearchBar
    participant searchHighlightedGeometryAtom
    participant MapLayer (Highlight)
    participant SearchHighlightRenderer

    User->>SearchBar: Hover over location result
    SearchBar->>searchHighlightedGeometryAtom: setHighlightedGeometry(item.geometry)
    searchHighlightedGeometryAtom->>MapLayer (Highlight): Notify of geometry change
    MapLayer (Highlight)->>SearchHighlightRenderer: Render new highlighted geometry

    User->>SearchBar: Mouse leaves result or menu closes
    SearchBar->>searchHighlightedGeometryAtom: setHighlightedGeometry(empty)
    searchHighlightedGeometryAtom->>MapLayer (Highlight): Notify of geometry change
    MapLayer (Highlight)->>SearchHighlightRenderer: Clear highlight

    User->>SearchBar: Click location result
    SearchBar->>itemSelectAction: select item
    itemSelectAction->>searchHighlightedGeometryAtom: setHighlightedGeometry(empty)
    itemSelectAction->>focusedGeometryAtom: Set focused geometry (if present)
    itemSelectAction->>focusOnGeometry: Focus map on geometry
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/update-location-selection-behavior

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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>, please review it.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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.

@github-actions
Copy link

Language To Recheck Fuzzy Untranslated Total
ar 3 216 837 1056
be 0 41 0 41
de 2 216 837 1055
es 3 216 837 1056
id 2 216 837 1055
ko 3 216 837 1056
ru 0 24 0 24
uk 0 18 799 817
zh 0 43 0 43

@github-actions
Copy link

github-actions bot commented Jul 30, 2025

Bundle size diff

Old size New size Diff
5.07 MB 5.07 MB 1.12 KB (0.02%)

@github-actions
Copy link

Preview environments for this PR:

These previews are automatically updated with each commit.

Note: After a new deployment, it may take a few minutes for the changes to propagate and for caches to update. During this time, you might experience temporary loading issues or see an older version of the app. If the app fails to load, please wait a few minutes and try again.

@codecov
Copy link

codecov bot commented Jul 30, 2025

Codecov Report

❌ Patch coverage is 0.83333% with 119 lines in your changes missing coverage. Please review.
✅ Project coverage is 11.98%. Comparing base (a738970) to head (f4ab61b).
⚠️ Report is 38 commits behind head on main.

Files with missing lines Patch % Lines
src/features/search/initSearchHighlightLayer.ts 0.00% 58 Missing and 1 partial ⚠️
.../features/search/componets/SearchBar/SearchBar.tsx 0.00% 26 Missing ⚠️
src/features/search/searchLocationAtoms.ts 0.00% 9 Missing ⚠️
src/features/search/atoms/highlightedGeometry.ts 0.00% 6 Missing and 1 partial ⚠️
src/features/search/index.tsx 0.00% 7 Missing ⚠️
src/features/search/constants.ts 14.28% 6 Missing ⚠️
src/features/search/searchAtoms.ts 0.00% 3 Missing ⚠️
...atures/search/renderers/SearchHighlightRenderer.ts 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1194      +/-   ##
==========================================
+ Coverage   11.57%   11.98%   +0.41%     
==========================================
  Files         720      728       +8     
  Lines       29639    29911     +272     
  Branches     1374     1402      +28     
==========================================
+ Hits         3431     3586     +155     
- Misses      25648    25766     +118     
+ Partials      560      559       -1     
Components Coverage Δ
UI Components 0.29% <ø> (-0.01%) ⬇️
Core Logic 17.19% <ø> (+0.05%) ⬆️
Features 2.54% <0.83%> (+1.11%) ⬆️
Utilities 44.60% <ø> (+0.21%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codecov
Copy link

codecov bot commented Jul 30, 2025

Bundle Report

Changes will increase total bundle size by 21.04kB (0.4%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
konturio/disaster-ninja-fe-esm 5.33MB 21.04kB (0.4%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: konturio/disaster-ninja-fe-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/vendor-*.js 8 bytes 676.01kB 0.0%
assets/index-*.js 287 bytes 2.85kB 11.21% ⚠️
assets/index-*.js -2.9kB 24.41kB -10.6%
assets/index-*.js 160 bytes 5.91kB 2.78%
assets/index-*.js -5 bytes 229.78kB -0.0%
assets/index-*.js 201 bytes 6.57kB 3.16%
assets/index-*.js 4 bytes 10.18kB 0.04%
assets/index-*.js -64 bytes 4.17kB -1.51%
assets/index-*.js 1 bytes 12.61kB 0.01%
assets/index-*.js -307 bytes 4.53kB -6.35%
assets/index-*.js 1.6kB 624.71kB 0.26%
assets/index-*.js -53 bytes 14.97kB -0.35%
assets/Map-*.js 20.84kB 624.58kB 3.45%
assets/SimpleTooltip-*.js -72 bytes 59.5kB -0.12%
assets/Map-*.css 423 bytes 31.27kB 1.37%
assets/index-*.css 34 bytes 1.51kB 2.31%
assets/index-*.css 54 bytes 786 bytes 7.38% ⚠️
assets/index-*.css 841 bytes 19.97kB 4.4%
assets/MultivariateRenderer-*.js -6 bytes 9.39kB -0.06%
assets/ConnectedMap-*.js -5 bytes 2.5kB -0.2%

Files in assets/Map-*.js:

  • ./src/features/search/searchLocationAtoms.ts → Total Size: 1.17kB

  • ./src/features/search/componets/SearchBar/SearchBar.tsx → Total Size: 6.3kB

  • ./src/features/search/atoms/highlightedGeometry.ts → Total Size: 137 bytes

  • ./src/features/search/searchAtoms.ts → Total Size: 1.72kB

  • ./src/features/search/index.tsx → Total Size: 1.85kB

  • ./src/features/search/renderers/SearchHighlightRenderer.ts → Total Size: 66 bytes

  • ./src/features/search/initSearchHighlightLayer.ts → Total Size: 1.32kB

  • ./src/features/search/constants.ts → Total Size: 168 bytes

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: 3

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 661197b and 164af39.

📒 Files selected for processing (8)
  • src/features/search/atoms/highlightedGeometry.ts (1 hunks)
  • src/features/search/componets/SearchBar/SearchBar.tsx (6 hunks)
  • src/features/search/constants.ts (1 hunks)
  • src/features/search/index.tsx (2 hunks)
  • src/features/search/initSearchHighlightLayer.ts (1 hunks)
  • src/features/search/readme.md (1 hunks)
  • src/features/search/renderers/SearchHighlightRenderer.ts (1 hunks)
  • src/features/search/searchLocationAtoms.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
PR: konturio/disaster-ninja-fe#0
File: AGENTS.md:0-0
Timestamp: 2025-07-24T13:49:18.225Z
Learning: Reference Fibery ticket in the PR description and headline.
src/features/search/readme.md (1)

Learnt from: CR
PR: konturio/disaster-ninja-fe#0
File: AGENTS.md:0-0
Timestamp: 2025-07-24T13:49:18.225Z
Learning: Applies to **/README.md : Every feature needs to have comprehensive up-to-date documentation in readme near it.

🧬 Code Graph Analysis (4)
src/features/search/renderers/SearchHighlightRenderer.ts (1)
src/features/boundary_selector/renderers/BoundarySelectorRenderer.ts (1)
  • BoundarySelectorRenderer (10-70)
src/features/search/atoms/highlightedGeometry.ts (1)
src/utils/geoJSON/helpers.ts (2)
  • FeatureCollection (4-10)
  • Feature (12-26)
src/features/search/searchLocationAtoms.ts (2)
src/core/focused_geometry/model.ts (1)
  • focusedGeometryAtom (7-46)
src/core/shared_state/currentMapPosition.ts (1)
  • focusOnGeometry (73-93)
src/features/search/index.tsx (1)
src/features/search/initSearchHighlightLayer.ts (1)
  • initSearchHighlightLayer (14-32)
🪛 markdownlint-cli2 (0.17.2)
src/features/search/readme.md

7-7: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


8-8: Lists should be surrounded by blank lines

(MD032, blanks-around-lists)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: deploy
  • GitHub Check: test
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (14)
src/features/search/constants.ts (1)

1-3: LGTM! Consider making color configurable.

The constants are well-named and follow conventions. The hardcoded black color works for the current requirement but consider making it theme-aware or configurable in the future for better accessibility.

src/features/search/atoms/highlightedGeometry.ts (1)

1-10: LGTM! Well-structured reactive atom.

The atom is properly configured with appropriate GeoJSON types and sensible initialization. The union type provides flexibility for different geometry formats.

src/features/search/index.tsx (1)

10-10: LGTM! Import added correctly.

src/features/search/renderers/SearchHighlightRenderer.ts (1)

1-3: LGTM! Clean inheritance pattern.

The empty extension provides semantic separation while reusing proven functionality from BoundarySelectorRenderer. This design allows for future search-specific customizations if needed.

src/features/search/initSearchHighlightLayer.ts (2)

12-16: LGTM: Proper singleton pattern implementation.

The initialization guard correctly prevents duplicate layer registration, which is essential for map layer management.


22-31: LGTM: Layer registration with proper configuration.

The layer registration follows the established pattern with appropriate constants, renderer, and configuration. The use of template literals for source ID generation is consistent.

src/features/search/searchLocationAtoms.ts (2)

11-15: LGTM: Proper imports for geometry focusing functionality.

The imports correctly bring in the required functions for both updating focused geometry state and camera positioning.


35-41: LGTM: Well-structured geometry focusing logic.

The conditional check prevents errors when geometry is missing, and the dual operation approach is appropriate:

  • setFocusedGeometry updates application state and triggers metrics
  • focusOnGeometry handles camera positioning

The 'custom' source type properly categorizes user-selected search results.

src/features/search/componets/SearchBar/SearchBar.tsx (6)

4-4: LGTM: Added useEffect import for cleanup functionality.


19-21: LGTM: Proper imports for highlighting functionality.

The imports correctly bring in the highlighted geometry atom and GeoJSON Feature type needed for the highlighting feature.


38-41: LGTM: Consistent action hook usage.

The useAction pattern follows the established codebase conventions for accessing atoms and actions.


53-57: LGTM: Proper cleanup on component unmount.

The cleanup effect correctly clears highlighted geometry when the component unmounts, preventing stale highlights from persisting.


103-110: LGTM: Proper hover highlighting for location items.

The mouse event handlers correctly:

  • Check for geometry existence before highlighting
  • Set geometry on mouseEnter and clear on mouseLeave
  • Use proper GeoJSON FeatureCollection structure for clearing

128-137: Confirmation: MCDA item hover behavior is intentional

The empty FeatureCollection in both onMouseEnter and onMouseLeave ensures that MCDA “create analysis” items—which don’t have any associated geometry—clear any existing highlights. No changes are required if this matches the intended UX.

• File: src/features/search/componets/SearchBar/SearchBar.tsx (lines 128–137)
• Handlers:

onMouseEnter: () =>
  setHighlightedGeometry({
    type: 'FeatureCollection',
    features: [],
  }),
onMouseLeave: () =>
  setHighlightedGeometry({
    type: 'FeatureCollection',
    features: [],
  }),

Copy link
Contributor

@alesiahil alesiahil left a comment

Choose a reason for hiding this comment

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

There is a layer with the weird name search.highlight_layer.settings.name - at least rename it to Administrative boundary
image

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 164af39 and 56339c9.

📒 Files selected for processing (1)
  • src/features/search/tests/highlightedAtom.test.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
PR: konturio/disaster-ninja-fe#0
File: AGENTS.md:0-0
Timestamp: 2025-07-24T13:49:18.225Z
Learning: Reference Fibery ticket in the PR description and headline.
src/features/search/tests/highlightedAtom.test.ts (2)

Learnt from: amurKontur
PR: #727
File: e2e/page-objects/helperBase.ts:0-0
Timestamp: 2024-06-10T19:32:46.895Z
Learning: The closeAtlasBanner method in the HelperBase class is covered by existing tests in e2e/popupPopulation.spec.ts, e2e/login.spec.ts, e2e/location.spec.ts, and e2e/auth.setup.ts.

Learnt from: amurKontur
PR: #727
File: playwright.config.ts:59-66
Timestamp: 2024-06-10T19:32:46.895Z
Learning: The webkit project configuration in playwright.config.ts is covered by tests that do not match the testIgnore patterns /WithUser/ and location.spec.ts.

🧬 Code Graph Analysis (1)
src/features/search/tests/highlightedAtom.test.ts (4)
src/core/store/store.ts (1)
  • store (7-7)
e2e/fixtures/test-options.ts (1)
  • test (10-27)
src/features/search/atoms/highlightedGeometry.ts (1)
  • searchHighlightedGeometryAtom (4-10)
src/utils/geoJSON/helpers.ts (1)
  • Feature (12-26)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: deploy
  • GitHub Check: test
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (2)
src/features/search/tests/highlightedAtom.test.ts (2)

1-4: LGTM!

The imports are well-structured and include all necessary dependencies for testing the atom functionality.


6-8: LGTM!

The store setup correctly creates an isolated test environment using Reatom's v3 context, which is the proper approach for unit testing atoms.

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

♻️ Duplicate comments (1)
src/features/search/readme.md (1)

1-12: Fix markdown formatting and grammar issues.

The documentation content is comprehensive and accurately describes the search feature functionality. However, there are formatting issues that should be addressed for better readability.

Apply this diff to fix the formatting issues:

 # Search feature
+
 This feature provides a search bar to find locations or MCDA analysis suggestions.
 Selected locations become the focused area on the map.
-While hovering over location results the geometry is highlighted on the map with a black outline.
+While hovering over location results, the geometry is highlighted on the map with a black outline.
 
 ## Main parts
+
-- `SearchBar` - UI component with dropdown results.
-- `searchLocationAtoms.ts` - handles locations fetching and selection.
-- `searchAtoms.ts` - aggregates MCDA and location results.
-- `atoms/highlightedGeometry.ts` - stores geometry highlighted on hover.
-- `initSearchHighlightLayer` - registers temporary map layer for hovered geometries.
+- `SearchBar` – UI component with dropdown results.
+- `searchLocationAtoms.ts` – handles locations fetching and selection.
+- `searchAtoms.ts` – aggregates MCDA and location results.
+- `atoms/highlightedGeometry.ts` – stores geometry highlighted on hover.
+- `initSearchHighlightLayer` – registers temporary map layer for hovered geometries.
+
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 56339c9 and 74c1322.

📒 Files selected for processing (4)
  • src/features/search/constants.ts (1 hunks)
  • src/features/search/index.tsx (2 hunks)
  • src/features/search/initSearchHighlightLayer.ts (1 hunks)
  • src/features/search/readme.md (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
PR: konturio/disaster-ninja-fe#0
File: AGENTS.md:0-0
Timestamp: 2025-07-24T13:49:18.225Z
Learning: Reference Fibery ticket in the PR description and headline.
src/features/search/readme.md (2)

Learnt from: CR
PR: konturio/disaster-ninja-fe#0
File: AGENTS.md:0-0
Timestamp: 2025-07-24T13:49:18.225Z
Learning: Applies to **/README.md : Every feature needs to have comprehensive up-to-date documentation in readme near it.

Learnt from: amurKontur
PR: #718
File: src/core/localization/extractLinkAndLabelFromMarkdown.ts:26-28
Timestamp: 2024-06-10T19:32:46.895Z
Learning: The extractLinkAndLabels function in src/core/localization/extractLinkAndLabelFromMarkdown.ts assumes the text node is always the first child of the link node, and this implementation is confirmed to be acceptable by user amurKontur.

🧬 Code Graph Analysis (2)
src/features/search/index.tsx (1)
src/features/search/initSearchHighlightLayer.ts (1)
  • initSearchHighlightLayer (13-70)
src/features/search/initSearchHighlightLayer.ts (5)
src/core/store/store.ts (1)
  • store (7-7)
src/features/search/constants.ts (2)
  • SEARCH_HIGHLIGHT_LAYER_ID (1-1)
  • SEARCH_HIGHLIGHT_COLOR (2-2)
src/features/search/renderers/SearchHighlightRenderer.ts (1)
  • SearchHighlightRenderer (3-3)
src/core/logical_layers/types/logicalLayer.ts (1)
  • LogicalLayerState (10-28)
src/features/search/atoms/highlightedGeometry.ts (1)
  • searchHighlightedGeometryAtom (4-10)
🪛 LanguageTool
src/features/search/readme.md

[grammar] ~1-~1: Use correct spacing
Context: # Search feature This feature provides a search bar to fi...

(QB_NEW_EN_OTHER_ERROR_IDS_5)


[grammar] ~5-~5: Use a comma after introductory words or phrases
Context: ...n the map. While hovering over location results the geometry is highlighted on the map ...

(QB_NEW_EN_OTHER_ERROR_IDS_19)


[grammar] ~5-~5: Use correct spacing
Context: ... is highlighted on the map with a black outline. ## Main parts - SearchBar - UI component ...

(QB_NEW_EN_OTHER_ERROR_IDS_5)


[grammar] ~7-~7: Use hyphens correctly
Context: ... the map with a black outline. ## Main parts - SearchBar - UI component with dropdown results. - ...

(QB_NEW_EN_OTHER_ERROR_IDS_29)


[grammar] ~9-~9: There might be a problem here.
Context: ...down results. - searchLocationAtoms.ts - handles locations fetching and selection. - `searchAtoms....

(QB_NEW_EN_MERGED_MATCH)


[grammar] ~10-~10: Use correct spacing
Context: ...tching and selection. - searchAtoms.ts - aggregates MCDA and location results. -...

(QB_NEW_EN_OTHER_ERROR_IDS_5)


[grammar] ~11-~11: Use correct spacing
Context: ...esults. - atoms/highlightedGeometry.ts - stores geometry highlighted on hover. -...

(QB_NEW_EN_OTHER_ERROR_IDS_5)


[grammar] ~12-~12: Use correct spacing
Context: ...d on hover. - initSearchHighlightLayer - registers temporary map layer for hover...

(QB_NEW_EN_OTHER_ERROR_IDS_5)

🪛 markdownlint-cli2 (0.17.2)
src/features/search/readme.md

7-7: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


8-8: Lists should be surrounded by blank lines

(MD032, blanks-around-lists)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: test
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (3)
src/features/search/constants.ts (1)

1-2: LGTM! Well-structured constants.

The constants are appropriately named and centralized, following good practices for configuration management. The black color aligns with the documented behavior of highlighting geometries with a black outline.

src/features/search/index.tsx (1)

22-27: LGTM! Proper lifecycle management implemented.

The useEffect correctly initializes the search highlight layer on mount and properly cleans it up on unmount by capturing and invoking the returned cleanup function. This addresses the previous review concern about missing cleanup logic.

src/features/search/initSearchHighlightLayer.ts (1)

13-70: LGTM! Well-implemented singleton pattern with proper lifecycle management.

The implementation correctly handles:

  • Singleton initialization to prevent duplicate layers
  • Proper error handling when map is unavailable
  • Reactive subscription to geometry changes with cleanup
  • Complete renderer lifecycle management

The previous review concern about subscription cleanup has been properly addressed.

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 74c1322 and 29c97c2.

📒 Files selected for processing (2)
  • src/features/search/initSearchHighlightLayer.ts (1 hunks)
  • src/features/search/tests/highlightedAtom.test.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
PR: konturio/disaster-ninja-fe#0
File: AGENTS.md:0-0
Timestamp: 2025-07-24T13:49:18.225Z
Learning: Reference Fibery ticket in the PR description and headline.
src/features/search/tests/highlightedAtom.test.ts (4)

Learnt from: amurKontur
PR: #727
File: e2e/page-objects/helperBase.ts:0-0
Timestamp: 2024-06-10T19:32:46.895Z
Learning: The closeAtlasBanner method in the HelperBase class is covered by existing tests in e2e/popupPopulation.spec.ts, e2e/login.spec.ts, e2e/location.spec.ts, and e2e/auth.setup.ts.

Learnt from: amurKontur
PR: #727
File: playwright.config.ts:59-66
Timestamp: 2024-06-10T19:32:46.895Z
Learning: The webkit project configuration in playwright.config.ts is covered by tests that do not match the testIgnore patterns /WithUser/ and location.spec.ts.

Learnt from: CR
PR: konturio/disaster-ninja-fe#0
File: AGENTS.md:0-0
Timestamp: 2025-07-24T13:49:18.225Z
Learning: Code test coverage is measured by codecov. Write useful tests to increase it and check key requirements to hold.

Learnt from: amurKontur
PR: #727
File: e2e/page-objects/helperBase.ts:52-65
Timestamp: 2024-06-10T19:32:46.895Z
Learning: The getTextsFromAllLocators method in e2e/page-objects/helperBase.ts is used within the test logic in e2e/page-objects/mapPage.ts, confirming its coverage by tests.

🧬 Code Graph Analysis (2)
src/features/search/initSearchHighlightLayer.ts (6)
src/core/store/store.ts (1)
  • store (7-7)
src/features/search/constants.ts (2)
  • SEARCH_HIGHLIGHT_LAYER_ID (1-1)
  • SEARCH_HIGHLIGHT_COLOR (2-2)
src/features/search/renderers/SearchHighlightRenderer.ts (1)
  • SearchHighlightRenderer (3-3)
src/core/logical_layers/types/logicalLayer.ts (1)
  • LogicalLayerState (10-28)
src/features/search/atoms/highlightedGeometry.ts (1)
  • searchHighlightedGeometryAtom (4-10)
src/utils/geoJSON/helpers.ts (2)
  • FeatureCollection (4-10)
  • Feature (12-26)
src/features/search/tests/highlightedAtom.test.ts (4)
src/core/store/store.ts (1)
  • store (7-7)
e2e/fixtures/test-options.ts (1)
  • test (10-27)
src/features/search/atoms/highlightedGeometry.ts (1)
  • searchHighlightedGeometryAtom (4-10)
src/utils/geoJSON/helpers.ts (2)
  • Feature (12-26)
  • FeatureCollection (4-10)
🔇 Additional comments (3)
src/features/search/tests/highlightedAtom.test.ts (1)

10-99: Excellent test coverage addressing previous feedback.

The test suite now comprehensively covers all the scenarios mentioned in the previous review, including different geometry types (Point, Polygon, LineString), FeatureCollections with multiple features, empty collections, and null values. This provides robust verification of the atom's behavior across all supported input scenarios.

src/features/search/initSearchHighlightLayer.ts (2)

51-71: Well-implemented subscription management and cleanup.

The subscription to searchHighlightedGeometryAtom now properly captures the unsubscribe function and includes it in the cleanup mechanism. This addresses the memory leak concern from previous reviews by ensuring the subscription is properly torn down when the layer is destroyed.


14-19: Good singleton pattern implementation with proper guard conditions.

The function correctly prevents multiple initializations and handles the case where no map is available. The early return of an existing cleanup function maintains the singleton behavior effectively.

@alesiahil alesiahil requested a review from a team August 3, 2025 00:36
Copy link
Contributor

@alesiahil alesiahil left a comment

Choose a reason for hiding this comment

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

Not sure if the black highlighting is needed because you will rarely see it on the map. And if you show black line after selection, you need to show the legend. It's inconsistent with the admin boundary selector which does not show the black contour after selection.

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: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 05b9304 and 783e529.

📒 Files selected for processing (4)
  • src/features/search/componets/SearchBar/SearchBar.tsx (6 hunks)
  • src/features/search/constants.ts (1 hunks)
  • src/features/search/searchAtoms.ts (2 hunks)
  • src/features/search/tests/searchAtoms.test.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
PR: konturio/disaster-ninja-fe#0
File: AGENTS.md:0-0
Timestamp: 2025-07-24T13:49:18.225Z
Learning: Reference Fibery ticket in the PR description and headline.
📚 Learning: the `closeatlasbanner` method in the `helperbase` class is covered by existing tests in `e2e/popuppo...
Learnt from: amurKontur
PR: konturio/disaster-ninja-fe#727
File: e2e/page-objects/helperBase.ts:0-0
Timestamp: 2024-06-10T19:32:46.895Z
Learning: The `closeAtlasBanner` method in the `HelperBase` class is covered by existing tests in `e2e/popupPopulation.spec.ts`, `e2e/login.spec.ts`, `e2e/location.spec.ts`, and `e2e/auth.setup.ts`.

Applied to files:

  • src/features/search/tests/searchAtoms.test.ts
📚 Learning: the `gettextsfromalllocators` method in `e2e/page-objects/helperbase.ts` is used within the test log...
Learnt from: amurKontur
PR: konturio/disaster-ninja-fe#727
File: e2e/page-objects/helperBase.ts:52-65
Timestamp: 2024-06-10T19:32:46.895Z
Learning: The `getTextsFromAllLocators` method in `e2e/page-objects/helperBase.ts` is used within the test logic in `e2e/page-objects/mapPage.ts`, confirming its coverage by tests.

Applied to files:

  • src/features/search/tests/searchAtoms.test.ts
📚 Learning: the `webkit` project configuration in `playwright.config.ts` is covered by tests that do not match t...
Learnt from: amurKontur
PR: konturio/disaster-ninja-fe#727
File: playwright.config.ts:59-66
Timestamp: 2024-06-10T19:32:46.895Z
Learning: The `webkit` project configuration in `playwright.config.ts` is covered by tests that do not match the `testIgnore` patterns `/WithUser/` and `location.spec.ts`.

Applied to files:

  • src/features/search/tests/searchAtoms.test.ts
🧬 Code Graph Analysis (4)
src/features/search/constants.ts (1)
src/utils/geoJSON/helpers.ts (1)
  • FeatureCollection (4-10)
src/features/search/searchAtoms.ts (2)
src/features/search/atoms/highlightedGeometry.ts (1)
  • searchHighlightedGeometryAtom (4-10)
src/features/search/constants.ts (1)
  • EMPTY_HIGHLIGHT (5-8)
src/features/search/tests/searchAtoms.test.ts (3)
src/core/store/store.ts (1)
  • store (7-7)
src/features/search/atoms/highlightedGeometry.ts (1)
  • searchHighlightedGeometryAtom (4-10)
src/features/search/searchAtoms.ts (1)
  • itemSelectAction (62-69)
src/features/search/componets/SearchBar/SearchBar.tsx (4)
src/features/search/searchAtoms.ts (4)
  • itemSelectAction (62-69)
  • resetSearchAction (71-74)
  • AggregatedSearchItem (21-26)
  • aggregatedSearchAtom (28-52)
src/features/search/atoms/highlightedGeometry.ts (1)
  • searchHighlightedGeometryAtom (4-10)
src/features/search/constants.ts (1)
  • EMPTY_HIGHLIGHT (5-8)
src/utils/geoJSON/helpers.ts (1)
  • Feature (12-26)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: comment
  • GitHub Check: test
🔇 Additional comments (10)
src/features/search/searchAtoms.ts (2)

15-16: Good integration of highlight clearing imports.

The imports are appropriately added to support the new highlighting functionality.


68-68: Proper cleanup of highlights on item selection.

Clearing the highlighted geometry when an item is selected provides good UX by ensuring stale highlights don't persist after selection.

src/features/search/tests/searchAtoms.test.ts (2)

2-15: Comprehensive mocking setup for isolated testing.

The mock setup properly isolates the unit under test by mocking external dependencies including metrics and related search atoms.


24-40: Well-structured test for highlight clearing behavior.

The test properly verifies that itemSelectAction clears the highlighted geometry state. The test data is realistic and the assertion is clear and focused.

src/features/search/componets/SearchBar/SearchBar.tsx (6)

4-4: Good addition of required imports for highlighting functionality.

The imports properly support the new highlighting feature with useEffect for lifecycle management and the necessary atoms and constants.

Also applies to: 19-21


42-42: Proper action setup for geometry highlighting.

The setHighlightedGeometry action is correctly set up using the useAction hook.


55-59: Good cleanup on component unmount.

The useEffect properly clears highlighted geometry when the component unmounts, preventing potential memory leaks or stale state.


105-109: Effective hover highlighting for location items.

The mouse event handlers properly highlight geometry on hover and clear it on leave, providing good visual feedback to users.


127-130: Appropriate handling for MCDA items.

Since MCDA items don't have geometry to highlight, clearing the highlight on both mouse enter and leave is the correct approach.


170-172: Proper cleanup when menu closes.

Clearing highlights when the menu closes ensures a clean state and prevents stale highlights from persisting.

@Komzpa
Copy link
Member Author

Komzpa commented Aug 3, 2025

@alesiahil fixed, please take another look

@Komzpa Komzpa requested a review from alesiahil August 3, 2025 04:08
@alesiahil alesiahil requested a review from a team August 3, 2025 10:01
@Komzpa Komzpa merged commit 16eee94 into main Aug 27, 2025
24 of 26 checks passed
@Komzpa Komzpa deleted the codex/update-location-selection-behavior branch August 27, 2025 10:54
albaranau added a commit that referenced this pull request Aug 27, 2025
Komzpa pushed a commit that referenced this pull request Aug 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants