…222022)
# Backport
This will backport the following commits from `main` to `8.19`:
- [[LensEmbeddable] Add "Open in lens" in the same tab
(#217528)](#217528)
<!--- Backport version: 10.0.0 -->
### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)
<!--BACKPORT [{"author":{"name":"Maria
Iriarte","email":"106958839+mariairiartef@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-05-26T16:25:56Z","message":"[LensEmbeddable]
Add \"Open in lens\" in the same tab (#217528)\n\n## Summary\n\nCloses
https://github.com/elastic/kibana/issues/204155\n\nAdds support for the
following behaviors:\n\n1. Clicking \"Open in Lens\" opens the Lens
editor in the same tab.\n2. Using Command (or Ctrl if is not an apple
device) + Click opens the\nLens editor in a new tab.\n\n> [!NOTE]\n>
This is a temporary workaround until a more comprehensive
solution,\nwhich requires additional effort, is implemented.\n\n###
Details\n\nThe goal is that by clicking on the \"Open in Lens\" button,
the Lens\neditor is opened in the current tab, and by Command +
Clicking, the Lens\neditor is opened in a separate tab. Currently, the
approach uses the\n`navigateToPrefilledEditor` method, exposed by the
Lens plugin, which is\ncalled upon execution of the
action.\n\nInitially, the idea was to use the shortUrl service to
generate a share\nURL. This service generates an Elasticsearch object,
which can be\nexcessive since the requirement doesn’t imply generating a
URL that can\nbe shared.\n\nWith the current approach, the data is
persisted because it is in the\nsession storage. That is why when we
click on the button and it opens in\na new tab, you can see the data.
However, if you copy the same URL to\nanother tab, nothing appears
because there’s no data.\n\nIf we want to add an href by specifying the
`getHref` method to the\naction (as
suggested\n[here](https://github.com/elastic/kibana/issues/204155#issuecomment-2578218129),\nit
won’t work as you cannot persist the data when you click on a
link.\n\nTo maintain the requested behavior, we update the openInNewTab
parameter\nthat is passed to the Lens `navigateToPrefilledEditor` method
to be true\nwhen it is a modified event or false when it is not.\n\n##
Checklist\n\n- [ ] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [ ] [Flaky
Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\nused on any tests changed\n- [ ] The PR description includes the
appropriate Release Notes section,\nand the correct `release_note:*`
label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"ca1d622ed0501b937490d56e16a7cf33c61cab09","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement","Team:Visualizations","Feature:Lens","backport:version","v9.1.0","v8.19.0"],"title":"[LensEmbeddable]
Add \"Open in lens\" in the same
tab","number":217528,"url":"https://github.com/elastic/kibana/pull/217528","mergeCommit":{"message":"[LensEmbeddable]
Add \"Open in lens\" in the same tab (#217528)\n\n## Summary\n\nCloses
https://github.com/elastic/kibana/issues/204155\n\nAdds support for the
following behaviors:\n\n1. Clicking \"Open in Lens\" opens the Lens
editor in the same tab.\n2. Using Command (or Ctrl if is not an apple
device) + Click opens the\nLens editor in a new tab.\n\n> [!NOTE]\n>
This is a temporary workaround until a more comprehensive
solution,\nwhich requires additional effort, is implemented.\n\n###
Details\n\nThe goal is that by clicking on the \"Open in Lens\" button,
the Lens\neditor is opened in the current tab, and by Command +
Clicking, the Lens\neditor is opened in a separate tab. Currently, the
approach uses the\n`navigateToPrefilledEditor` method, exposed by the
Lens plugin, which is\ncalled upon execution of the
action.\n\nInitially, the idea was to use the shortUrl service to
generate a share\nURL. This service generates an Elasticsearch object,
which can be\nexcessive since the requirement doesn’t imply generating a
URL that can\nbe shared.\n\nWith the current approach, the data is
persisted because it is in the\nsession storage. That is why when we
click on the button and it opens in\na new tab, you can see the data.
However, if you copy the same URL to\nanother tab, nothing appears
because there’s no data.\n\nIf we want to add an href by specifying the
`getHref` method to the\naction (as
suggested\n[here](https://github.com/elastic/kibana/issues/204155#issuecomment-2578218129),\nit
won’t work as you cannot persist the data when you click on a
link.\n\nTo maintain the requested behavior, we update the openInNewTab
parameter\nthat is passed to the Lens `navigateToPrefilledEditor` method
to be true\nwhen it is a modified event or false when it is not.\n\n##
Checklist\n\n- [ ] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [ ] [Flaky
Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\nused on any tests changed\n- [ ] The PR description includes the
appropriate Release Notes section,\nand the correct `release_note:*`
label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"ca1d622ed0501b937490d56e16a7cf33c61cab09"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/217528","number":217528,"mergeCommit":{"message":"[LensEmbeddable]
Add \"Open in lens\" in the same tab (#217528)\n\n## Summary\n\nCloses
https://github.com/elastic/kibana/issues/204155\n\nAdds support for the
following behaviors:\n\n1. Clicking \"Open in Lens\" opens the Lens
editor in the same tab.\n2. Using Command (or Ctrl if is not an apple
device) + Click opens the\nLens editor in a new tab.\n\n> [!NOTE]\n>
This is a temporary workaround until a more comprehensive
solution,\nwhich requires additional effort, is implemented.\n\n###
Details\n\nThe goal is that by clicking on the \"Open in Lens\" button,
the Lens\neditor is opened in the current tab, and by Command +
Clicking, the Lens\neditor is opened in a separate tab. Currently, the
approach uses the\n`navigateToPrefilledEditor` method, exposed by the
Lens plugin, which is\ncalled upon execution of the
action.\n\nInitially, the idea was to use the shortUrl service to
generate a share\nURL. This service generates an Elasticsearch object,
which can be\nexcessive since the requirement doesn’t imply generating a
URL that can\nbe shared.\n\nWith the current approach, the data is
persisted because it is in the\nsession storage. That is why when we
click on the button and it opens in\na new tab, you can see the data.
However, if you copy the same URL to\nanother tab, nothing appears
because there’s no data.\n\nIf we want to add an href by specifying the
`getHref` method to the\naction (as
suggested\n[here](https://github.com/elastic/kibana/issues/204155#issuecomment-2578218129),\nit
won’t work as you cannot persist the data when you click on a
link.\n\nTo maintain the requested behavior, we update the openInNewTab
parameter\nthat is passed to the Lens `navigateToPrefilledEditor` method
to be true\nwhen it is a modified event or false when it is not.\n\n##
Checklist\n\n- [ ] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [ ] [Flaky
Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\nused on any tests changed\n- [ ] The PR description includes the
appropriate Release Notes section,\nand the correct `release_note:*`
label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"ca1d622ed0501b937490d56e16a7cf33c61cab09"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
Summary
Closes #204155
Adds support for the following behaviors:
Note
This is a temporary workaround until a more comprehensive solution, which requires additional effort, is implemented.
Details
The goal is that by clicking on the "Open in Lens" button, the Lens editor is opened in the current tab, and by Command + Clicking, the Lens editor is opened in a separate tab. Currently, the approach uses the
navigateToPrefilledEditormethod, exposed by the Lens plugin, which is called upon execution of the action.Initially, the idea was to use the shortUrl service to generate a share URL. This service generates an Elasticsearch object, which can be excessive since the requirement doesn’t imply generating a URL that can be shared.
With the current approach, the data is persisted because it is in the session storage. That is why when we click on the button and it opens in a new tab, you can see the data. However, if you copy the same URL to another tab, nothing appears because there’s no data.
If we want to add an href by specifying the
getHrefmethod to the action (as suggested here, it won’t work as you cannot persist the data when you click on a link.To maintain the requested behavior, we update the openInNewTab parameter that is passed to the Lens
navigateToPrefilledEditormethod to be true when it is a modified event or false when it is not.Checklist
release_note:*label is applied per the guidelines