Skip to content

Commit 6e9abf9

Browse files
dbchristopherLuke Bowerman
andauthored
Revert "toggle css visibility in HoverDisclosure" (#1561)
* Revert "toggle css visibility in HoverDisclosure" * Update changelog and tests This reverts commit 28afb99. Co-authored-by: Luke Bowerman <[email protected]>
1 parent b611cb8 commit 6e9abf9

File tree

5 files changed

+11
-41
lines changed

5 files changed

+11
-41
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [UNRELEASED]
99

1010
- `useDialog` needs to support scenario it is controlled but `onClose` isn't specified
11+
- Reverts: `HoverDisclosure` toggles visibility with css rather than inserting elements into the DOM
1112
- `Space` revert mistakenly applied `flex-shrink: 0`
1213

1314
## [0.9.17] - 2020-10-12

packages/components/src/Button/size.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export const buttonSizeMap = {
6969
export const iconButtonIconSizeMap = {
7070
xxsmall: 'xxsmall',
7171
xsmall: 'xsmall',
72-
small: 'xsmall',
72+
small: 'small',
7373
medium: 'small',
7474
large: 'medium',
7575
}

packages/components/src/Tree/Tree.test.tsx

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,9 @@ describe('Tree', () => {
158158
</Tree>
159159
)
160160

161-
expect(screen.queryByText('Tree Detail')?.parentElement).toHaveStyleRule(
162-
'visibility',
163-
'hidden'
164-
)
161+
expect(screen.queryByText('Tree Detail')).not.toBeInTheDocument()
165162
fireEvent.mouseEnter(screen.getByText('Tree Label'), { bubbles: true })
166-
expect(screen.queryByText('Tree Detail')?.parentElement).toHaveStyleRule(
167-
'visibility',
168-
'visible'
169-
)
163+
expect(screen.queryByText('Tree Detail')).toBeInTheDocument()
170164
})
171165

172166
test("Child Tree adopts Parent Tree's detailHoverDisclosure prop value (when Child Tree does not have prop value)", () => {
@@ -183,17 +177,11 @@ describe('Tree', () => {
183177
</Tree>
184178
)
185179

186-
expect(screen.queryByText('Child Detail')?.parentElement).toHaveStyleRule(
187-
'visibility',
188-
'hidden'
189-
)
180+
expect(screen.queryByText('Child Detail')).not.toBeInTheDocument()
190181
fireEvent.mouseEnter(screen.getByText('Child Label'), {
191182
bubbles: true,
192183
})
193-
expect(screen.queryByText('Child Detail')?.parentElement).toHaveStyleRule(
194-
'visibility',
195-
'visible'
196-
)
184+
expect(screen.queryByText('Child Detail')).toBeInTheDocument()
197185
})
198186

199187
test("Child Tree detailHoverDisclosure prop value overrides Parent Tree's detailHoverDisclosure prop value", () => {

packages/components/src/Tree/TreeItem.test.tsx

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,9 @@ describe('TreeItem', () => {
6868
</TreeItem>
6969
)
7070

71-
expect(screen.queryByText('Detail')?.parentElement).toHaveStyleRule(
72-
'visibility',
73-
'hidden'
74-
)
71+
expect(screen.queryByText('Detail')).not.toBeInTheDocument()
7572
fireEvent.mouseEnter(screen.getByText('Label'), { bubbles: true })
76-
expect(screen.queryByText('Detail')?.parentElement).toHaveStyleRule(
77-
'visibility',
78-
'visible'
79-
)
73+
expect(screen.queryByText('Detail')).toBeInTheDocument()
8074
})
8175

8276
test("Child TreeItem adopts Parent Tree's detailHoverDisclosure prop value (when Child TreeItem does not have detailHoverDisclosure prop value)", () => {
@@ -91,15 +85,9 @@ describe('TreeItem', () => {
9185
</Tree>
9286
)
9387

94-
expect(screen.queryByText('Child Detail')?.parentElement).toHaveStyleRule(
95-
'visibility',
96-
'hidden'
97-
)
88+
expect(screen.queryByText('Child Detail')).not.toBeInTheDocument()
9889
fireEvent.mouseEnter(screen.getByText('Child Label'), { bubbles: true })
99-
expect(screen.queryByText('Child Detail')?.parentElement).toHaveStyleRule(
100-
'visibility',
101-
'visible'
102-
)
90+
expect(screen.queryByText('Child Detail')).toBeInTheDocument()
10391
})
10492

10593
test("Child TreeItem's detailHoverDisclosure prop value overrides Parent Tree's detailHoverDisclosure prop value", () => {

packages/components/src/utils/HoverDisclosure/HoverDisclosure.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
*/
2626

2727
import React, { FC, useContext } from 'react'
28-
import styled from 'styled-components'
2928
import { HoverDisclosureContext } from './HoverDisclosureContext'
3029

3130
export interface HoverDisclosureProps {
@@ -37,11 +36,5 @@ export const HoverDisclosure: FC<HoverDisclosureProps> = ({
3736
visible,
3837
}) => {
3938
const context = useContext(HoverDisclosureContext)
40-
return (
41-
<Disclosure visible={visible || context.visible}>{children}</Disclosure>
42-
)
39+
return visible || context.visible ? <>{children}</> : null
4340
}
44-
45-
const Disclosure = styled.span<HoverDisclosureProps>`
46-
visibility: ${({ visible }) => (visible ? 'visible' : 'hidden')};
47-
`

0 commit comments

Comments
 (0)