Skip to content

Commit 7e1a75d

Browse files
committed
fix: Reset target position and additional attribute on destroy properly
1 parent 0cd40d2 commit 7e1a75d

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/Tooltip.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ class Tooltip {
128128
}
129129

130130
async destroy() {
131-
this.#target.setAttribute('style', 'position: null')
132-
this.#target.setAttribute('aria-describedby', null)
131+
this.#target.style.removeProperty('position')
132+
this.#target.removeAttribute('aria-describedby')
133133

134134
await this.#removeTooltipFromTarget()
135135

src/__tests__/useTooltip.test.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ describe('useTooltip', () => {
6161
it('Shows tooltip on mouse enter', async () => {
6262
action = useTooltip(target, options)
6363
await _enter(target)
64+
expect(target).toHaveStyle('position: relative')
65+
expect(target).toHaveAttribute('aria-describedby')
6466
expect(getElement('#content')).toBeInTheDocument()
6567
})
6668

@@ -124,7 +126,8 @@ describe('useTooltip', () => {
124126
it('Destroys tooltip', async () => {
125127
action = useTooltip(target, options)
126128
action.destroy(target)
127-
expect(target).toHaveStyle('position: null')
129+
expect(target).not.toHaveStyle('position: relative')
130+
expect(target).not.toHaveAttribute('aria-describedby')
128131
await _enter(target)
129132
expect(getElement('#content')).not.toBeInTheDocument()
130133
})

0 commit comments

Comments
 (0)