-
Notifications
You must be signed in to change notification settings - Fork 46
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
Conversation
Codecov ReportAttention: Patch coverage is
❗ 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
69950e6
to
7b3b6ee
Compare
There was a problem hiding this 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
front/src/applications/stdcmV2/components/StdcmOperationalPoint.tsx
Outdated
Show resolved
Hide resolved
front/src/applications/stdcmV2/components/StdcmOperationalPoint.tsx
Outdated
Show resolved
Hide resolved
@@ -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( |
There was a problem hiding this comment.
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?)
There was a problem hiding this comment.
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.
Signed-off-by: romainvalls <[email protected]>
7b3b6ee
to
256ca19
Compare
There was a problem hiding this 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
Added a dependency to operationalPointsSuggestions, previous input value isn't visible anymore while typing a new value. |
@@ -53,7 +57,7 @@ const StdcmOperationalPoint = ({ | |||
if (!isDuplicate) acc.push(newObject); | |||
return acc; | |||
}, [] as Option[]), | |||
[sortedSearchResults] | |||
[sortedSearchResults, handleBlur] |
There was a problem hiding this comment.
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.
There was a problem hiding this 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'; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
Not relevant anymore, the bug was fixed by this PR: #10293 |
closes #9296