playbook_ui 12.34.0.pre.alpha.play716popoverkitcloseonclickissue998 → 12.34.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: de8314a6b967b5e972e46892edd4fe1c7b9dfcb9ca199120cc898e92724b137a
4
- data.tar.gz: 4f323f8d98c5219d26de002ed897bf31ab5dee71af172727559e3b1aca47b04c
3
+ metadata.gz: f2849c0a1962557e91163c1111e59d583658a23463c747fa5416e5f57a9a8fdb
4
+ data.tar.gz: 529c7267dde24349b1fe48203b2c631faeb186a74dd83021979929607b2dec51
5
5
  SHA512:
6
- metadata.gz: 2fb6010127b3e609045f7b7b6ba41aa650ed266e00b8b0660a4b9e544568300b2a7a7722a6b43f9913bc2791ef7234522b303433a566fa52bf95345ecf13ef89
7
- data.tar.gz: 4bf867ee4ee1ef8fa70d12a0fd5bd61efbdbab94d0a7b03f3060857eac345c75c4de7a02bb65ef200f5a5c1e801317d6e8208e55cba22f8fee32a553728860ae
6
+ metadata.gz: 8d88ffe25dba254906c2e9c1fe43d0f34f8fc88d7176a6f22ba50f96798aa23acb2e71dc37feb8c2d24aabd2283603987c29813473b7fcce218d6d5f137ecbd5
7
+ data.tar.gz: 3079579c4f39e39ba29596493995fd21eb33722368106f82fdc8e81ac0c374217a5c81823d8f8dd29d85abf70bef8adefb1efddc132e920997166615c98c77b8
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useState } from "react";
1
+ import React, { useEffect } from "react";
2
2
  import ReactDOM from "react-dom";
3
3
  import {
4
4
  Popper,
@@ -17,7 +17,6 @@ import {
17
17
 
18
18
  import classnames from "classnames";
19
19
  import { globalProps, GlobalProps } from "../utilities/globalProps";
20
- import _uniqueId from 'lodash/uniqueId';
21
20
 
22
21
  type PbPopoverProps = {
23
22
  aria?: { [key: string]: string };
@@ -73,7 +72,6 @@ const Popover = (props: PbPopoverProps) => {
73
72
  maxWidth,
74
73
  minHeight,
75
74
  minWidth,
76
- targetId,
77
75
  } = props;
78
76
 
79
77
  const popoverSpacing =
@@ -125,7 +123,6 @@ const Popover = (props: PbPopoverProps) => {
125
123
  popoverSpacing,
126
124
  overflowHandling
127
125
  )}
128
- id={targetId}
129
126
  style={widthHeightStyles()}
130
127
  >
131
128
  {children}
@@ -139,7 +136,6 @@ const Popover = (props: PbPopoverProps) => {
139
136
  };
140
137
 
141
138
  const PbReactPopover = (props: PbPopoverProps) => {
142
- const [targetId] = useState(_uniqueId('id-'))
143
139
  const {
144
140
  className,
145
141
  children,
@@ -167,27 +163,25 @@ const PbReactPopover = (props: PbPopoverProps) => {
167
163
  "click",
168
164
  ({ target }) => {
169
165
  const targetIsPopover =
170
- (target as HTMLElement).closest("#" + targetId) !==
166
+ (target as HTMLElement).closest("[class^=pb_popover_tooltip]") !==
171
167
  null;
172
168
  const targetIsReference =
173
- (target as HTMLElement).closest("#reference-" + targetId) !==
169
+ (target as HTMLElement).closest(".pb_popover_reference_wrapper") !==
174
170
  null;
175
171
 
176
172
  switch (closeOnClick) {
177
173
  case "outside":
178
- if (!targetIsPopover && !targetIsReference) {
174
+ if (!targetIsPopover || targetIsReference) {
179
175
  shouldClosePopover(true);
180
176
  }
181
177
  break;
182
178
  case "inside":
183
- if (targetIsPopover) {
179
+ if (targetIsPopover || targetIsReference) {
184
180
  shouldClosePopover(true);
185
181
  }
186
182
  break;
187
183
  case "any":
188
- if (targetIsPopover || !targetIsPopover && !targetIsReference) {
189
- shouldClosePopover(true);
190
- }
184
+ shouldClosePopover(true);
191
185
  break;
192
186
  }
193
187
  },
@@ -206,7 +200,6 @@ const PbReactPopover = (props: PbPopoverProps) => {
206
200
  offset={offset}
207
201
  placement={placement}
208
202
  referenceElement={referenceElement}
209
- targetId={targetId}
210
203
  zIndex={zIndex}
211
204
  {...props}
212
205
  >
@@ -221,7 +214,6 @@ const PbReactPopover = (props: PbPopoverProps) => {
221
214
  <PopperReference>
222
215
  {({ ref }) => (
223
216
  <span
224
- id={"reference-" + targetId}
225
217
  className="pb_popover_reference_wrapper"
226
218
  ref={ref}>
227
219
  <reference.type {...reference.props} />
@@ -24,7 +24,6 @@ const PopoverClose = (props) => {
24
24
 
25
25
  const handleOutsideTogglePopover = () => {
26
26
  setOutsideShowPopover(!showOutsidePopover)
27
- setAnyShowPopover(false)
28
27
  }
29
28
 
30
29
  const handleAnyShouldClosePopover = (shouldClosePopover) => {
@@ -33,7 +32,6 @@ const PopoverClose = (props) => {
33
32
 
34
33
  const handleAnyTogglePopover = () => {
35
34
  setAnyShowPopover(!showAnyPopover)
36
- setOutsideShowPopover(false)
37
35
  }
38
36
 
39
37
  const insidePopoverTrigger = (
@@ -49,16 +49,13 @@ export default class PbPopover extends PbEnhancedElement {
49
49
  checkCloseTooltip() {
50
50
  document.querySelector('body').addEventListener('click', ({ target } ) => {
51
51
  const isTooltipElement = (target as HTMLElement).closest(`#${this.tooltipId}`) !== null
52
- const isTriggerElement = (target as HTMLElement).closest(`#${this.triggerElementId}`) !== null
53
52
 
54
53
  switch (this.closeOnClick) {
55
54
  case 'any':
56
- if (isTooltipElement || !isTooltipElement && !isTriggerElement) {
57
- this.hideTooltip()
58
- }
55
+ this.hideTooltip()
59
56
  break
60
57
  case 'outside':
61
- if (!isTooltipElement && !isTriggerElement) {
58
+ if (!isTooltipElement) {
62
59
  this.hideTooltip()
63
60
  }
64
61
  break