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

[Discover] Fix "Options" link in top nav #101136

Conversation

kertal
Copy link
Member

@kertal kertal commented Jun 2, 2021

Summary

WIP

  • Closes Options popover once clicked a second time

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@kertal kertal self-assigned this Jun 2, 2021
@kertal kertal added the Feature:Discover Discover Application label Jun 2, 2021
@kertal kertal changed the title [Discover] Fix options link [Discover] Fix "Options" link in top nav Jun 2, 2021
@kibanamachine
Copy link
Contributor

⏳ Build in-progress, with failures

Failed CI Steps

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

cc @kertal

@timroes
Copy link
Contributor

timroes commented Jun 2, 2021

I think we could have a bit simpler implementation for this (aligning more with e.g. what dashboard does):

--- a/src/plugins/discover/public/application/components/top_nav/open_options_popover.tsx
+++ b/src/plugins/discover/public/application/components/top_nav/open_options_popover.tsx
@@ -16,6 +16,7 @@ import { getServices } from '../../../kibana_services';
 import './open_options_popover.scss';
 import { DOC_TABLE_LEGACY } from '../../../../common';
 
+const container = document.createElement('div');
 let isOpen = false;
 
 interface OptionsPopoverProps {
@@ -82,6 +83,12 @@ export function OptionsPopover(props: OptionsPopoverProps) {
   );
 }
 
+function onClose() {
+  ReactDOM.unmountComponentAtNode(container);
+  document.body.removeChild(container);
+  isOpen = false;
+}
+
 export function openOptionsPopover({
   I18nContext,
   anchorElement,
@@ -90,17 +97,11 @@ export function openOptionsPopover({
   anchorElement: HTMLElement;
 }) {
   if (isOpen) {
+    onClose();
     return;
   }
 
   isOpen = true;
-  const container = document.createElement('div');
-  const onClose = () => {
-    ReactDOM.unmountComponentAtNode(container);
-    document.body.removeChild(container);
-    isOpen = false;
-  };
-
   document.body.appendChild(container);
 
   const element = (

@timroes
Copy link
Contributor

timroes commented Jun 2, 2021

Superseeded by #101154

@timroes timroes closed this Jun 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Discover Discover Application
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants