From bd315cc0fae1b11076751099aa294641f907d1c9 Mon Sep 17 00:00:00 2001
From: Corey Robertson <corey.robertson@elastic.co>
Date: Tue, 14 Jan 2020 14:09:18 -0500
Subject: [PATCH] Fixes bugs with full screen filters

---
 .../time_picker_popover/time_picker_popover.tsx       | 11 ++++++++++-
 .../canvas/public/components/element_wrapper/index.js |  4 +++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/time_picker_popover.tsx b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/time_picker_popover.tsx
index 1dafd7ba648c3..8f6061b688319 100644
--- a/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/time_picker_popover.tsx
+++ b/x-pack/legacy/plugins/canvas/canvas_plugin_src/renderers/time_filter/components/time_picker_popover/time_picker_popover.tsx
@@ -42,7 +42,16 @@ export const TimePickerPopover: FunctionComponent<Props> = ({ from, to, onSelect
       anchorClassName="canvasTimePickerPopover__anchor"
       button={button}
     >
-      {() => <TimePicker from={from} to={to} onSelect={onSelect} />}
+      {({ closePopover }) => (
+        <TimePicker
+          from={from}
+          to={to}
+          onSelect={(...args) => {
+            onSelect(...args);
+            closePopover();
+          }}
+        />
+      )}
     </Popover>
   );
 };
diff --git a/x-pack/legacy/plugins/canvas/public/components/element_wrapper/index.js b/x-pack/legacy/plugins/canvas/public/components/element_wrapper/index.js
index 1934eab85d034..60c7e731691fa 100644
--- a/x-pack/legacy/plugins/canvas/public/components/element_wrapper/index.js
+++ b/x-pack/legacy/plugins/canvas/public/components/element_wrapper/index.js
@@ -58,7 +58,9 @@ function selectorFactory(dispatch) {
 export const ElementWrapper = compose(
   connectAdvanced(selectorFactory),
   withPropsOnChange(
-    (props, nextProps) => !isEqual(props.element, nextProps.element),
+    (props, nextProps) =>
+      !isEqual(props.element, nextProps.element) ||
+      !isEqual(props.selectedPage, nextProps.selectedPage),
     props => {
       const { element, createHandlers } = props;
       const handlers = createHandlers(element, props.selectedPage);