Skip to content
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

Fix issue with navigating in firefox/safari #65163

Merged
merged 2 commits into from
May 4, 2020

Conversation

timroes
Copy link
Contributor

@timroes timroes commented May 4, 2020

Summary

Fix #65090

This fixes an issue in Visualize that you cannot navigate to create new visualizations (that don't require an index pattern, like TSVB or Vega). The reason for this issue happening is that the history object that we use in multiple methods, and also in removeQueryParam, won't reflect the new URL instantly in Firefox and Safari, since they fire the hashchange event a bit delayed. So the removeQueryParam method will still see the /visualize URL (and not /visualize/create as it should when creating a new visualization), and then just remove a parameter from it (or not) and navigate to it, i.e. it navigates back to the table where it's coming from, because it never saw the new URL.

The long term fix for this is described in #65161, but will require significant larger changes, which are out of the scope of a fix for 7.7.0.

This fix will simply make sure we're waiting one execution slot before finishing the navigation to /visualize/create (and only that page). This will cause the Editor Angular Controller to be instantiated one execution slot later, in which case history always reflects the correct URL (/visualize/create). Since we're only waiting one execution slot (and no specific amount of ms), there won't be any noticeable delay introduced by that change.

Regarding tests: I have no idea how we could properly test this, since this is based on specific browser behavior in Firefox/Safari, that we cannot easily catch in any unit test and in a functional test only in Firefox. Thus I think we cannot provide any proper test for this PR, but the correct "test" for this is to work towards enabling the functional visualization tests in the firefox test suite.

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@timroes timroes requested a review from a team May 4, 2020 19:47
@timroes timroes added blocker bug Fixes for quality problems that affect the customer experience Feature:Vis Editor Visualization editor issues Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.7.0 v7.8.0 v8.0.0 labels May 4, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

@timroes timroes added the release_note:skip Skip the PR/issue when compiling release notes label May 4, 2020
@bhavyarm
Copy link
Contributor

bhavyarm commented May 4, 2020

Tested this on - on create visualizations and from create new on dashboards and on both safari and firefox latest. I picked creating TSVB, vega, timelion, area, pie, gauge, and markdown using visualize in both browsers & randomized them. Also default and non-default spaces. AFAIK - nothing broke in chrome because of this fix. Needs IE testing.

Copy link
Member

@lukeelmers lukeelmers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code changes here LGTM; thanks for linking directly to the follow-up task in the code 👍

Tested this PR locally (macOS) in Chrome, Safari, Firefox, and am no longer able to reproduce the issue (I'm able to consistently reproduce on master). Also tried a handful of vis types and all seems to be behaving normally.

Regarding tests: I have no idea how we could properly test this, since this is based on specific browser behavior in Firefox/Safari, that we cannot easily catch in any unit test and in a functional test only in Firefox. Thus I think we cannot provide any proper test for this PR, but the correct "test" for this is to work towards enabling the functional visualization tests in the firefox test suite.

I agree with this assessment; I'm not really sure how we'd automate a test for this without browser-specific functional tests for visualizations.

return data.indexPatterns
.ensureDefaultIndexPattern(history)
.then(() => savedVisualizations.get($route.current.params))
.then(getResolvedResults(deps))
.then(delay)
.catch(
Copy link
Contributor

@wylieconlon wylieconlon May 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edit: I needed to reread some docs on Chained Promises.

Won't this .catch no longer catch errors from the getResolvedResults function, since the delay function can never throw an error? This looks like it could inadvertently cause our error handling behavior to be different

Copy link
Contributor

@wylieconlon wylieconlon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've compared the behavior of the 7.x branch against this PR in Chrome, Firefox, and Safari, and wasn't able to consistently reproduce the bug in any browser. Your explanation makes sense and is definitely a workaround that I've used with the angular router in past projects, so I think this is a fine change. The behavior definitely doesn't get worse with this change.

My comment about error handling logic was based on my testing with unrealistic error messages: It looks like we handle errors from the SavedObjectLoader in a custom way.

Copy link
Contributor

@ThomThomson ThomThomson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix LGTM,
Tested via creating timelion, vega, and TSVB charts from the visualizations listing.

Tested on:
Chrome on osx
Firefox on osx
Safari on osx

Waiting on updates in order to test with IE 11

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@timroes timroes merged commit 09deb23 into elastic:master May 4, 2020
@timroes timroes deleted the fix/navigation-issues branch May 4, 2020 22:06
timroes pushed a commit to timroes/kibana that referenced this pull request May 4, 2020
timroes pushed a commit to timroes/kibana that referenced this pull request May 4, 2020
# Conflicts:
#	src/plugins/visualize/public/application/legacy_app.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker bug Fixes for quality problems that affect the customer experience Feature:Vis Editor Visualization editor issues release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.7.0 v7.8.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot create a new visualization in Firefox and Safari
7 participants