Skip to content

Commit

Permalink
fix: Reset target position and additional attribute on destroy properly
Browse files Browse the repository at this point in the history
  • Loading branch information
untemps committed Oct 6, 2022
1 parent 0cd40d2 commit 7e1a75d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ class Tooltip {
}

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

await this.#removeTooltipFromTarget()

Expand Down
5 changes: 4 additions & 1 deletion src/__tests__/useTooltip.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ describe('useTooltip', () => {
it('Shows tooltip on mouse enter', async () => {
action = useTooltip(target, options)
await _enter(target)
expect(target).toHaveStyle('position: relative')
expect(target).toHaveAttribute('aria-describedby')
expect(getElement('#content')).toBeInTheDocument()
})

Expand Down Expand Up @@ -124,7 +126,8 @@ describe('useTooltip', () => {
it('Destroys tooltip', async () => {
action = useTooltip(target, options)
action.destroy(target)
expect(target).toHaveStyle('position: null')
expect(target).not.toHaveStyle('position: relative')
expect(target).not.toHaveAttribute('aria-describedby')
await _enter(target)
expect(getElement('#content')).not.toBeInTheDocument()
})
Expand Down

0 comments on commit 7e1a75d

Please sign in to comment.