Skip to content

Stop Discover's Visualize button from loading incorrect URL#8721

Merged
Bargs merged 1 commit intoelastic:masterfrom
Bargs:fixVizUrl
Oct 17, 2016
Merged

Stop Discover's Visualize button from loading incorrect URL#8721
Bargs merged 1 commit intoelastic:masterfrom
Bargs:fixVizUrl

Conversation

@Bargs
Copy link
Contributor

@Bargs Bargs commented Oct 17, 2016

When App state is read from the url, it is accessed via
$location.search(). It turns out that the result of
$location.search() is a mutable object that allows you to modify the
results of $location.search() without actually modifying the URL. When
a user clicks a field in the Discover sidebar, it executes the scope
method vizLocation to get the href value for the "Visualize" button.
As an unintended side effect, vizLocation was modifying the object
returned from $location.search(). This change would ultimately be read
when the Visualize app loaded instead of the param in the actual URL
since there's no full page load from Discover -> Visualize.

To make things more complicated, I believe there was a race condition
partially masking this issue. Since vizLocation is used in an Angular
string template, the data binding causes it to execute on every digest
cycle. This is why the incorrect value continued to be written to
$location.search() even after visLocation ran for the correct field.
It also meant that the result of $location.search() was totally
dependent on which field vizLocation ran for most recently before the
user clicked Visualize.

Fixes #8718

When App state is read from the url, it is accessed via
`$location.search()`. It turns out that the result of
`$location.search()` is a mutable object that allows you to modify the
results of `$location.search()` without actually modifying the URL. When
a user clicks a field in the Discover sidebar, it executes the scope
method `vizLocation` to get the href value for the "Visualize" button.
As an unintended side effect, `vizLocation` was modifying the object
returned from `$location.search()`. This change would ultimately be read
when the Visualize app loaded instead of the param in the actual URL
since there's no full page load from Discover -> Visualize.

To make things more complicated, I believe there was a race condition
partially masking this issue. Since `vizLocation` is used in an Angular
string template, the data binding causes it to execute on every digest
cycle. This is why the incorrect value continued to be written to
`$location.search()` even after `visLocation` ran for the correct field.
It also meant that the result of `$location.search()` was totally
dependent on which field `vizLocation` ran for most recently before the
user clicked Visualize.

Fixes elastic#8718
@Bargs
Copy link
Contributor Author

Bargs commented Oct 17, 2016

I just confirmed this issue existed in 4.x as well so I think the fix can wait until 5.1.

@Bargs Bargs removed the v5.0.0 label Oct 17, 2016
@thomasneirynck thomasneirynck self-assigned this Oct 17, 2016
@Bargs Bargs merged commit c8e6fae into elastic:master Oct 17, 2016
elastic-jasper added a commit that referenced this pull request Oct 17, 2016
---------

**Commit 1:**
Stop Discover's Visualize button from loading incorrect URL

When App state is read from the url, it is accessed via
`$location.search()`. It turns out that the result of
`$location.search()` is a mutable object that allows you to modify the
results of `$location.search()` without actually modifying the URL. When
a user clicks a field in the Discover sidebar, it executes the scope
method `vizLocation` to get the href value for the "Visualize" button.
As an unintended side effect, `vizLocation` was modifying the object
returned from `$location.search()`. This change would ultimately be read
when the Visualize app loaded instead of the param in the actual URL
since there's no full page load from Discover -> Visualize.

To make things more complicated, I believe there was a race condition
partially masking this issue. Since `vizLocation` is used in an Angular
string template, the data binding causes it to execute on every digest
cycle. This is why the incorrect value continued to be written to
`$location.search()` even after `visLocation` ran for the correct field.
It also meant that the result of `$location.search()` was totally
dependent on which field `vizLocation` ran for most recently before the
user clicked Visualize.

Fixes #8718

* Original sha: d0d926b
* Authored by Matthew Bargar <mbargar@gmail.com> on 2016-10-17T21:07:11Z
Bargs pushed a commit that referenced this pull request Oct 17, 2016
@epixa epixa added v5.1.1 and removed v5.1.0 labels Dec 8, 2016
airow pushed a commit to airow/kibana that referenced this pull request Feb 16, 2017
---------

**Commit 1:**
Stop Discover's Visualize button from loading incorrect URL

When App state is read from the url, it is accessed via
`$location.search()`. It turns out that the result of
`$location.search()` is a mutable object that allows you to modify the
results of `$location.search()` without actually modifying the URL. When
a user clicks a field in the Discover sidebar, it executes the scope
method `vizLocation` to get the href value for the "Visualize" button.
As an unintended side effect, `vizLocation` was modifying the object
returned from `$location.search()`. This change would ultimately be read
when the Visualize app loaded instead of the param in the actual URL
since there's no full page load from Discover -> Visualize.

To make things more complicated, I believe there was a race condition
partially masking this issue. Since `vizLocation` is used in an Angular
string template, the data binding causes it to execute on every digest
cycle. This is why the incorrect value continued to be written to
`$location.search()` even after `visLocation` ran for the correct field.
It also meant that the result of `$location.search()` was totally
dependent on which field `vizLocation` ran for most recently before the
user clicked Visualize.

Fixes elastic#8718

* Original sha: a839d2bbfef59996f51f2e2ddacf2e5d1a1d9fd3 [formerly d0d926b]
* Authored by Matthew Bargar <mbargar@gmail.com> on 2016-10-17T21:07:11Z


Former-commit-id: e7e228f
airow pushed a commit to airow/kibana that referenced this pull request Feb 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants