From 0150c8e8cf98bffde0ab5c428d7075ab4cce3726 Mon Sep 17 00:00:00 2001 From: Dario Gieselaar Date: Fri, 23 Aug 2019 14:28:03 +0200 Subject: [PATCH] [APM] Update query input when url changes (#43773) Closes #42135. --- .../public/components/shared/KueryBar/Typeahead/index.js | 9 +++++---- .../apm/public/components/shared/KueryBar/index.tsx | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/x-pack/legacy/plugins/apm/public/components/shared/KueryBar/Typeahead/index.js b/x-pack/legacy/plugins/apm/public/components/shared/KueryBar/Typeahead/index.js index 71f40fd4815dc..b1b4419502957 100644 --- a/x-pack/legacy/plugins/apm/public/components/shared/KueryBar/Typeahead/index.js +++ b/x-pack/legacy/plugins/apm/public/components/shared/KueryBar/Typeahead/index.js @@ -26,13 +26,15 @@ export class Typeahead extends Component { isSuggestionsVisible: false, index: null, value: '', - inputIsPristine: true + initialValue: '' }; static getDerivedStateFromProps(props, state) { - if (state.inputIsPristine && props.initialValue) { + const { initialValue } = props; + if (initialValue && initialValue !== state.initialValue) { return { - value: props.initialValue + value: initialValue, + initialValue }; } @@ -125,7 +127,6 @@ export class Typeahead extends Component { const hasValue = Boolean(value.trim()); this.setState({ value, - inputIsPristine: false, isSuggestionsVisible: hasValue, index: null }); diff --git a/x-pack/legacy/plugins/apm/public/components/shared/KueryBar/index.tsx b/x-pack/legacy/plugins/apm/public/components/shared/KueryBar/index.tsx index cc885fabb74db..9fe8be856ece4 100644 --- a/x-pack/legacy/plugins/apm/public/components/shared/KueryBar/index.tsx +++ b/x-pack/legacy/plugins/apm/public/components/shared/KueryBar/index.tsx @@ -188,7 +188,7 @@ export function KueryBar() { return; } - history.replace({ + history.push({ ...location, search: fromQuery({ ...toQuery(location.search),