Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit a805341

Browse files
authored
fix(Popup): fix broken background with pointing and FocusTrap (#1689)
* fix(Popup): fix broken background with pointing and FocusTrap * update CHANGELOG * fix for render callback * fix comment
1 parent 379d928 commit a805341

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
2323

2424
### Fixes
2525
- Fix a gap in `Checkbox` in RTL mode @layershifter ([#1683](https://github.com/stardust-ui/react/pull/1683))
26+
- Fix broken background in `Popup` with `pointing` and `FocusTrap` @layershifter ([#1689](https://github.com/stardust-ui/react/pull/1689))
2627

2728
<!--------------------------------[ v0.34.1 ]------------------------------- -->
2829
## [v0.34.1](https://github.com/stardust-ui/react/tree/v0.34.1) (2019-07-11)

packages/react/src/themes/teams/components/Popup/popupStyles.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,35 @@
1+
import * as _ from 'lodash'
2+
import * as React from 'react'
13
import { ComponentSlotStylesInput, ICSSInJSStyle } from '../../../types'
24
import { PopupProps } from '../../../../components/Popup/Popup'
35
import { PopupVariables } from './popupVariables'
46

57
const popupStyles: ComponentSlotStylesInput<PopupProps, PopupVariables> = {
68
root: (): ICSSInJSStyle => ({}),
79

8-
popup: ({ variables: v }): ICSSInJSStyle => ({
10+
popup: ({ props: p, variables: v }): ICSSInJSStyle => ({
911
zIndex: v.zIndex,
1012
position: 'absolute',
1113
textAlign: 'left',
12-
color: v.contentColor,
13-
background: v.contentBackgroundColor,
14+
15+
/*
16+
* This fix handles all cases with wrapped focus trap.
17+
*/
18+
...((React.isValidElement(p.content) || _.isFunction(p.content)) && {
19+
// when FocusTrap exists and `context` is JSX element or render() callback
20+
color: v.contentColor,
21+
background: v.contentBackgroundColor,
22+
}),
23+
'&.ui-popup__content': {
24+
// when there is no FocusTrap
25+
color: v.contentColor,
26+
background: v.contentBackgroundColor,
27+
},
28+
'& .ui-popup__content': {
29+
// when FocusTrap exists
30+
color: v.contentColor,
31+
background: v.contentBackgroundColor,
32+
},
1433
}),
1534
}
1635

0 commit comments

Comments
 (0)