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

front: fix combo box suggestions in stdcm #9447

Closed
wants to merge 2 commits into from

Conversation

RomainValls
Copy link
Contributor

closes #9296

@RomainValls RomainValls requested a review from a team as a code owner October 24, 2024 10:06
@codecov-commenter
Copy link

codecov-commenter commented Oct 24, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.

Project coverage is 39.61%. Comparing base (bae2942) to head (5b35e80).
Report is 621 commits behind head on dev.

Files with missing lines Patch % Lines
...dcm/components/StdcmForm/StdcmOperationalPoint.tsx 0.00% 9 Missing and 1 partial ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##                dev    #9447      +/-   ##
============================================
- Coverage     39.62%   39.61%   -0.02%     
  Complexity     2270     2270              
============================================
  Files          1300     1300              
  Lines         99158    99173      +15     
  Branches       3282     3283       +1     
============================================
- Hits          39294    39283      -11     
- Misses        57931    57957      +26     
  Partials       1933     1933              
Flag Coverage Δ
core 75.06% <ø> (-0.02%) ⬇️
editoast 73.27% <ø> (-0.04%) ⬇️
front 10.23% <0.00%> (-0.01%) ⬇️
gateway 2.19% <ø> (ø)
osrdyne 3.28% <ø> (-0.01%) ⬇️
railjson_generator 87.49% <ø> (ø)
tests 86.71% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@RomainValls RomainValls force-pushed the rvs/front-fix-combo-box-suggestions-in-stdcm branch from 69950e6 to 7b3b6ee Compare October 24, 2024 10:10
@RomainValls RomainValls self-assigned this Oct 24, 2024
Copy link
Contributor

@Akctarus Akctarus left a comment

Choose a reason for hiding this comment

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

Tested, We still have a frame in which the old filter is still displayed when a new letter is typed, but it disappears immediately, seems fine to me

@@ -30,13 +30,13 @@ const StdcmOperationalPoint = ({
disabled,
}: StdcmOperationalPointProps) => {
const { t } = useTranslation('stdcm');
const [suggestionsVisible, setSuggestionsVisible] = useState(false);

const { searchTerm, chCodeFilter, sortedSearchResults, setSearchTerm, setChCodeFilter } =
useSearchOperationalPoint({ initialSearchTerm: point?.name, initialChCodeFilter: point?.ch });

const operationalPointsSuggestions = useMemo(
Copy link
Member

@emersion emersion Oct 25, 2024

Choose a reason for hiding this comment

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

I think this useMemo is missing a dependency on searchTerm? Same deal with sortedChOptions below.

(With that fixed, maybe we don't need suggestionsVisible at all?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tried adding the missing dependencies on operationalPointsSuggestions and sortedChOptions, the behavior of the input remaining in memory is still here.

@RomainValls RomainValls force-pushed the rvs/front-fix-combo-box-suggestions-in-stdcm branch from 7b3b6ee to 256ca19 Compare October 28, 2024 15:19
Copy link
Contributor

@theocrsb theocrsb left a comment

Choose a reason for hiding this comment

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

There's still the problem @Akctarus pointed out

@RomainValls
Copy link
Contributor Author

Added a dependency to operationalPointsSuggestions, previous input value isn't visible anymore while typing a new value.
There's still a frame, after typing in the input, where the suggestions seem to be sorted again, but this is the behavior in dev.

@@ -53,7 +57,7 @@ const StdcmOperationalPoint = ({
if (!isDuplicate) acc.push(newObject);
return acc;
}, [] as Option[]),
[sortedSearchResults]
[sortedSearchResults, handleBlur]
Copy link
Member

Choose a reason for hiding this comment

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

handleBlur is not used inside this useMemo, and since a new function is created each time the component is re-rendered, this effectively always re-computes operationalPointsSuggestions, making useMemo useless.

Copy link
Member

@emersion emersion left a comment

Choose a reason for hiding this comment

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

When typing something, then clicking elsewhere, it seems like the first result is selected. From the issue, the expected result is that the input field is cleared.

@@ -1,4 +1,4 @@
import { useEffect, useMemo } from 'react';
import { useEffect, useMemo, useState } from 'react';

import { Select, ComboBox } from '@osrd-project/ui-core';
Copy link
Contributor

Choose a reason for hiding this comment

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

I think if we want to handle the case of parent's onChange passed to the ComboBox, this bug must be fixed in osrd-ui

Copy link
Contributor

Choose a reason for hiding this comment

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

Here is a draft to fix this in osrd-ui

@clarani
Copy link
Contributor

clarani commented Jan 9, 2025

Not relevant anymore, the bug was fixed by this PR: #10293

@clarani clarani closed this Jan 9, 2025
@clarani clarani deleted the rvs/front-fix-combo-box-suggestions-in-stdcm branch January 9, 2025 14:30
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.

stdcm: CI input keeps track of what was previously input, but without showing it
7 participants