-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[APM] Fix for default fields in correlations view (#91868) #92090
[APM] Fix for default fields in correlations view (#91868) #92090
Conversation
Pinging @elastic/apm-ui (Team:apm) |
@elasticmachine merge upstream |
} | ||
}, [key, defaultValue]); | ||
|
||
const [item, setItem] = useState<T>(getFromStorage()); |
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.
Can we avoid useCallback
and useEffect
if the arguments are passed to getFromStorage
?
const [item, setItem] = useState<T>(getFromStorage()); | |
const [item, setItem] = useState<T>(getFromStorage(key, defaultValue)); |
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 got rid of the useCallback
, but it still needs the useEffect
with dependencies on [key, defaultValue]
since changes in any of these should trigger a state change resulting in a new value for the returned item
. The lack of this update was the source of stale state in this issue. In correlations defaultValue
gets updates from a useFetcher
response (for dynamic index pattern). The new defaultValue
should be the item
value since this would be rendered as custom fields before any persistence happens.
@@ -26,7 +24,9 @@ export function useLocalStorage<T>(key: string, defaultValue: T) { | |||
} | |||
|
|||
return toStore; |
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.
While you are at it: do we need toStore
? Can't we just return immediately instead of mutating?
const storedItem = window.localStorage.getItem(key);
if (storedItem !== null) {
try {
return JSON.parse(storedItem) as T;
} catch (err) {
window.localStorage.removeItem(key);
// eslint-disable-next-line no-console
console.log(`Unable to decode: ${key}`);
}
}
return defaultValue;
@elasticmachine merge upstream |
💛 Build succeeded, but was flaky
Test FailuresKibana Pipeline / general / Chrome UI Functional Tests.test/functional/apps/dashboard/dashboard_filtering·ts.dashboard app using current data dashboard filtering disabling a filter unfilters the data on saved searchesStandard Out
Stack Trace
Metrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
…astic#92090) * [APM] Fix for default fields in correlations view (elastic#91868) * removes useCallback hook Co-authored-by: Kibana Machine <[email protected]>
…astic#92090) * [APM] Fix for default fields in correlations view (elastic#91868) * removes useCallback hook Co-authored-by: Kibana Machine <[email protected]>
…bana into task-manager/docs-monitoring * 'task-manager/docs-monitoring' of github.com:gmmorris/kibana: (40 commits) [Security Solution][Case][Bug] Improve case logging (elastic#91924) [Alerts][Doc] Added README documentation for alerts plugin status and framework health checks configuration options. (elastic#92761) Add warning for EQL and Threshold rules if exception list contains value list items (elastic#92914) [Security Solution][Case] Fix subcases bugs on detections and case view (elastic#91836) [APM] Always allow access to Profiling via URL (elastic#92889) [Vega] Allow image loading without CORS policy by changing the default to crossOrigin=null (elastic#91991) skip flaky suite (elastic#92114) [APM] Fix for default fields in correlations view (elastic#91868) (elastic#92090) chore(NA): bump bazelisk to v1.7.5 (elastic#92905) [Maps] fix selecting EMS basemap does not populate input (elastic#92711) API docs (elastic#92827) [kbn/test] add import/export support to KbnClient (elastic#92526) Test fix management scripted field filter functional test and unskip it (elastic#92756) [App Search] Create Curation view/functionality (elastic#92560) [Reporting/Discover] include the document's entire set of fields (elastic#92730) [Fleet] Add new index to fleet for artifacts being served out of fleet-server (elastic#92860) [Alerts][Doc] Added README documentation for API key invalidation configuration options. (elastic#92757) [Discover][docs] Add search for relevance (elastic#90611) [Alerts][Docs] Extended README.md and the user docs with the licensing information. (elastic#92564) [7.12][Telemetry] Security telemetry allowlist fix. (elastic#92850) ...
…92951) * [APM] Fix for default fields in correlations view (#91868) * removes useCallback hook Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Kibana Machine <[email protected]>
…92950) * [APM] Fix for default fields in correlations view (#91868) * removes useCallback hook Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Kibana Machine <[email protected]>
Closes #91868.
Updates the internal state in in the
useLocalStorage
hook whenever the default value changes.