Skip to content

Commit

Permalink
[ML] Single Metric Viewer: ensures chart displays correctly when open…
Browse files Browse the repository at this point in the history
…ing from a job annotation (elastic#182176)

## Summary

Fixes elastic#181910

Ensures the position of the zoom slider gets set correctly when user
navigates to the single metric viewer from the anomaly explorer page or
jobs list from annotations -> job model snapshots -> single metric
viewer.

This PR removes the previous forecast id comparison as it was never
getting correctly set so the `focusRange` was getting reset even when it
should not have been because it was already defined.

I believe this was introduced in
elastic#176969.


https://github.com/elastic/kibana/assets/6446462/cbd297ae-e3c2-43ab-ad06-27898ea06a3a

Confirming the link with forecast id still works as expected:



https://github.com/elastic/kibana/assets/6446462/9216c880-7bcf-4d46-b071-adb77f2db1e4


### Checklist

Delete any items that are not applicable to this PR.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
alvarezmelissa87 and kibanamachine committed May 1, 2024
1 parent 565a447 commit a1b990d
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,8 @@ export class TimeSeriesExplorer extends React.Component {
if (
// If the user's focus range is not defined (i.e. no 'zoom' parameter restored from the appState URL),
// then calculate the default focus range to use
zoom === undefined &&
(focusRange === undefined ||
this.previousSelectedForecastId !== this.props.selectedForecastId)
zoom === undefined ||
focusRange === undefined
) {
focusRange = this.mlTimeSeriesExplorer.calculateDefaultFocusRange(
autoZoomDuration,
Expand All @@ -476,10 +475,12 @@ export class TimeSeriesExplorer extends React.Component {
this.previousSelectedForecastId = this.props.selectedForecastId;
}

this.contextChartSelected({
from: focusRange[0],
to: focusRange[1],
});
if (focusRange !== undefined) {
this.contextChartSelected({
from: focusRange[0],
to: focusRange[1],
});
}
}

this.setState(stateUpdate);
Expand Down

0 comments on commit a1b990d

Please sign in to comment.