-
Notifications
You must be signed in to change notification settings - Fork 901
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
[Discover] Decouple data$
updates to prevent rows clearing on hook re-render
#8806
[Discover] Decouple data$
updates to prevent rows clearing on hook re-render
#8806
Conversation
…re-render Signed-off-by: Joshua Li <[email protected]>
❌ Empty Changelog SectionThe Changelog section in your PR description is empty. Please add a valid changelog entry or entries. If you did add a changelog entry, check to make sure that it was not accidentally included inside the comment block in the Changelog section. |
Signed-off-by: Joshua Li <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8806 +/- ##
==========================================
+ Coverage 60.78% 60.87% +0.08%
==========================================
Files 3798 3799 +1
Lines 90701 90761 +60
Branches 14284 14294 +10
==========================================
+ Hits 55135 55248 +113
+ Misses 32067 32004 -63
- Partials 3499 3509 +10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@joshuali925 can you add a UT atleast for your part of the change? |
Signed-off-by: Joshua Li <[email protected]>
Signed-off-by: Joshua Li <[email protected]>
useEffect(() => { | ||
data$.next({ ...data$.value, queryStatus: { startTime } }); | ||
}, [data$, startTime]); | ||
|
||
useEffect(() => { | ||
data$.next({ | ||
...data$.value, | ||
status: | ||
shouldSearchOnPageLoad() && !skipInitialFetch.current | ||
? ResultStatus.LOADING | ||
: ResultStatus.UNINITIALIZED, | ||
}); | ||
}, [data$, shouldSearchOnPageLoad, skipInitialFetch]); |
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.
Is there a reason why this is separated into two useEffect()
's? If mimicking the original useMemo()
, could be done in a single update and reduce the number of useEffects()
.
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.
startTime updates should only update queryStatus.startTime
and not reset status
. it's the bug this PR is trying to fix, we should decouple queryStatus and status updates
Signed-off-by: Joshua Li <[email protected]>
getTimeUpdate$: jest.fn(), | ||
getRefreshIntervalUpdate$: jest.fn(), | ||
getTimeUpdate$: jest.fn(() => new Observable<unknown>()), | ||
getRefreshIntervalUpdate$: jest.fn(() => new Observable<unknown>()), |
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.
not related to this pr, but think we need update codecov config to ignore mocks
…re-render (#8806) Signed-off-by: Joshua Li <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> (cherry picked from commit e664cd0) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
…re-render (#8806) (#8829) (cherry picked from commit e664cd0) Signed-off-by: Joshua Li <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Description
While #8552 is fixed by not letting query automatically run again, updating selected field still clears all rows in discover. This happens because any re-render to hook
useSearch
will cleardata$
by creating a new observable.This PR fixes it by decoupling update logic based on dependencies.
Issues Resolved
#8552
Screenshot
No UI change
Testing the changes
i don't see UT for
useSearch
, @LDrago27 could you take a look if they will break anything?Changelog
Check List
yarn test:jest
yarn test:jest_integration