Skip to content

Commit 0c9ff8f

Browse files
authored
Merge pull request #430 from CraveFood/force-popover-rerender
feat(Popover): remove content node from dom when popover is not visible
2 parents 4fcd617 + aae05c3 commit 0c9ff8f

File tree

2 files changed

+9
-219
lines changed

2 files changed

+9
-219
lines changed

packages/popover/src/Popover.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import styled from "styled-components";
44
import values from "object.values";
55
import Tooltip, { alignments } from "@crave/farmblocks-tooltip";
66

7-
const Container = styled.div`display: inline-block;`;
7+
const Container = styled.div`
8+
display: inline-block;
9+
`;
810

911
class Popover extends React.Component {
1012
state = {
@@ -47,7 +49,7 @@ class Popover extends React.Component {
4749
zIndex={this.props.zIndex}
4850
padding={this.props.padding}
4951
>
50-
{this.props.content(this.hide)}
52+
{this.state.isVisible && this.props.content(this.hide)}
5153
</Tooltip>
5254
</Container>
5355
);

packages/popover/src/__snapshots__/Popover.story.storyshot

+5-217
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,6 @@ exports[`Storyshots Popover Button as a trigger - Right aligned 1`] = `
55
position: relative;
66
}
77

8-
.c2 {
9-
-webkit-transition: visibility 0s linear 0.1s,opacity 0.1s linear;
10-
transition: visibility 0s linear 0.1s,opacity 0.1s linear;
11-
visibility: hidden;
12-
opacity: 0;
13-
position: absolute;
14-
z-index: 1000;
15-
top: 15px;
16-
padding: 8px;
17-
background-color: #ffffff;
18-
box-shadow: 0 2px 2px 0 rgba(0,0,0,0.16);
19-
border: solid 1px rgba(0,0,0,0.16);
20-
border-radius: 4px;
21-
white-space: pre;
22-
color: #2f313a;
23-
font-family: lato,sans-serif;
24-
right: 0;
25-
}
26-
27-
.c3 {
28-
font-family: Lato,sans-serif;
29-
font-size: 18px;
30-
-webkit-font-smoothing: antialiased;
31-
color: #2f313a;
32-
text-align: left;
33-
}
34-
358
.c0 {
369
display: inline-block;
3710
}
@@ -57,19 +30,7 @@ exports[`Storyshots Popover Button as a trigger - Right aligned 1`] = `
5730
</div>
5831
<div
5932
className="c1"
60-
>
61-
<div
62-
className="c2"
63-
>
64-
<div
65-
className="c3"
66-
size={18}
67-
type="#2f313a"
68-
>
69-
Popover content
70-
</div>
71-
</div>
72-
</div>
33+
/>
7334
</div>
7435
</div>
7536
`;
@@ -79,28 +40,6 @@ exports[`Storyshots Popover Center aligned 1`] = `
7940
position: relative;
8041
}
8142

82-
.c4 {
83-
-webkit-transition: visibility 0s linear 0.1s,opacity 0.1s linear;
84-
transition: visibility 0s linear 0.1s,opacity 0.1s linear;
85-
visibility: hidden;
86-
opacity: 0;
87-
position: absolute;
88-
z-index: 1000;
89-
top: 15px;
90-
padding: 8px;
91-
background-color: #ffffff;
92-
box-shadow: 0 2px 2px 0 rgba(0,0,0,0.16);
93-
border: solid 1px rgba(0,0,0,0.16);
94-
border-radius: 4px;
95-
white-space: pre;
96-
color: #2f313a;
97-
font-family: lato,sans-serif;
98-
left: 50%;
99-
-webkit-transform: translateX(-50%);
100-
-ms-transform: translateX(-50%);
101-
transform: translateX(-50%);
102-
}
103-
10443
.c1 {
10544
display: inline-block;
10645
}
@@ -155,14 +94,6 @@ exports[`Storyshots Popover Center aligned 1`] = `
15594
color: #2980b9;
15695
}
15796

158-
.c5 {
159-
font-family: Lato,sans-serif;
160-
font-size: 18px;
161-
-webkit-font-smoothing: antialiased;
162-
color: #2f313a;
163-
text-align: left;
164-
}
165-
16697
.c0 {
16798
display: inline-block;
16899
}
@@ -205,19 +136,7 @@ exports[`Storyshots Popover Center aligned 1`] = `
205136
</div>
206137
<div
207138
className="c3"
208-
>
209-
<div
210-
className="c4"
211-
>
212-
<div
213-
className="c5"
214-
size={18}
215-
type="#2f313a"
216-
>
217-
Centered Popover
218-
</div>
219-
</div>
220-
</div>
139+
/>
221140
</div>
222141
</div>
223142
`;
@@ -227,33 +146,6 @@ exports[`Storyshots Popover Custom padding 1`] = `
227146
position: relative;
228147
}
229148

230-
.c2 {
231-
-webkit-transition: visibility 0s linear 0.1s,opacity 0.1s linear;
232-
transition: visibility 0s linear 0.1s,opacity 0.1s linear;
233-
visibility: hidden;
234-
opacity: 0;
235-
position: absolute;
236-
z-index: 1000;
237-
top: 15px;
238-
padding: 50px;
239-
background-color: #ffffff;
240-
box-shadow: 0 2px 2px 0 rgba(0,0,0,0.16);
241-
border: solid 1px rgba(0,0,0,0.16);
242-
border-radius: 4px;
243-
white-space: pre;
244-
color: #2f313a;
245-
font-family: lato,sans-serif;
246-
left: 0;
247-
}
248-
249-
.c3 {
250-
font-family: Lato,sans-serif;
251-
font-size: 18px;
252-
-webkit-font-smoothing: antialiased;
253-
color: #2f313a;
254-
text-align: left;
255-
}
256-
257149
.c0 {
258150
display: inline-block;
259151
}
@@ -271,26 +163,7 @@ exports[`Storyshots Popover Custom padding 1`] = `
271163
</div>
272164
<div
273165
className="c1"
274-
>
275-
<div
276-
className="c2"
277-
>
278-
<div>
279-
<div
280-
className="c3"
281-
size={18}
282-
type="#2f313a"
283-
>
284-
Popover content
285-
</div>
286-
<button
287-
onClick={[Function]}
288-
>
289-
Dismiss
290-
</button>
291-
</div>
292-
</div>
293-
</div>
166+
/>
294167
</div>
295168
`;
296169

@@ -299,25 +172,6 @@ exports[`Storyshots Popover Default - Link as a trigger 1`] = `
299172
position: relative;
300173
}
301174

302-
.c4 {
303-
-webkit-transition: visibility 0s linear 0.1s,opacity 0.1s linear;
304-
transition: visibility 0s linear 0.1s,opacity 0.1s linear;
305-
visibility: hidden;
306-
opacity: 0;
307-
position: absolute;
308-
z-index: 1000;
309-
top: 15px;
310-
padding: 8px;
311-
background-color: #ffffff;
312-
box-shadow: 0 2px 2px 0 rgba(0,0,0,0.16);
313-
border: solid 1px rgba(0,0,0,0.16);
314-
border-radius: 4px;
315-
white-space: pre;
316-
color: #2f313a;
317-
font-family: lato,sans-serif;
318-
left: 0;
319-
}
320-
321175
.c1 {
322176
display: inline-block;
323177
}
@@ -372,14 +226,6 @@ exports[`Storyshots Popover Default - Link as a trigger 1`] = `
372226
color: #2980b9;
373227
}
374228

375-
.c5 {
376-
font-family: Lato,sans-serif;
377-
font-size: 18px;
378-
-webkit-font-smoothing: antialiased;
379-
color: #2f313a;
380-
text-align: left;
381-
}
382-
383229
.c0 {
384230
display: inline-block;
385231
}
@@ -414,19 +260,7 @@ exports[`Storyshots Popover Default - Link as a trigger 1`] = `
414260
</div>
415261
<div
416262
className="c3"
417-
>
418-
<div
419-
className="c4"
420-
>
421-
<div
422-
className="c5"
423-
size={18}
424-
type="#2f313a"
425-
>
426-
Popover content
427-
</div>
428-
</div>
429-
</div>
263+
/>
430264
</div>
431265
`;
432266

@@ -435,25 +269,6 @@ exports[`Storyshots Popover Dismissable 1`] = `
435269
position: relative;
436270
}
437271

438-
.c4 {
439-
-webkit-transition: visibility 0s linear 0.1s,opacity 0.1s linear;
440-
transition: visibility 0s linear 0.1s,opacity 0.1s linear;
441-
visibility: hidden;
442-
opacity: 0;
443-
position: absolute;
444-
z-index: 1000;
445-
top: 15px;
446-
padding: 8px;
447-
background-color: #ffffff;
448-
box-shadow: 0 2px 2px 0 rgba(0,0,0,0.16);
449-
border: solid 1px rgba(0,0,0,0.16);
450-
border-radius: 4px;
451-
white-space: pre;
452-
color: #2f313a;
453-
font-family: lato,sans-serif;
454-
left: 0;
455-
}
456-
457272
.c1 {
458273
display: inline-block;
459274
}
@@ -508,14 +323,6 @@ exports[`Storyshots Popover Dismissable 1`] = `
508323
color: #2980b9;
509324
}
510325

511-
.c5 {
512-
font-family: Lato,sans-serif;
513-
font-size: 18px;
514-
-webkit-font-smoothing: antialiased;
515-
color: #2f313a;
516-
text-align: left;
517-
}
518-
519326
.c0 {
520327
display: inline-block;
521328
}
@@ -550,25 +357,6 @@ exports[`Storyshots Popover Dismissable 1`] = `
550357
</div>
551358
<div
552359
className="c3"
553-
>
554-
<div
555-
className="c4"
556-
>
557-
<div>
558-
<div
559-
className="c5"
560-
size={18}
561-
type="#2f313a"
562-
>
563-
Popover content
564-
</div>
565-
<button
566-
onClick={[Function]}
567-
>
568-
Dismiss
569-
</button>
570-
</div>
571-
</div>
572-
</div>
360+
/>
573361
</div>
574362
`;

0 commit comments

Comments
 (0)