Skip to content

Commit

Permalink
Fix flip option (#432)
Browse files Browse the repository at this point in the history
  • Loading branch information
atomiks committed Feb 22, 2019
1 parent adf4a63 commit 0489381
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/js/createTippy.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ export default function createTippy(reference, collectionProps) {
},
},
onUpdate(data) {
if (!instance.props.flipOnUpdate) {
if (instance.props.flip && !instance.props.flipOnUpdate) {
if (data.flipped) {
instance.popperInstance.options.placement = data.placement
}
Expand Down Expand Up @@ -528,7 +528,10 @@ export default function createTippy(reference, collectionProps) {
instance.popperInstance.enableEventListeners()
}
}
setFlipModifierEnabled(instance.popperInstance.modifiers, true)
setFlipModifierEnabled(
instance.popperInstance.modifiers,
instance.props.flip,
)
}

// If the instance previously had followCursor behavior, it will be
Expand Down
8 changes: 8 additions & 0 deletions test/spec/defaults.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,14 @@ describe('flip', () => {
false,
)
})

it('does not change after mounting', () => {
const instance = tippy(h(), withTestOptions({ flip: false, duration: 0 }))
instance.show()
expect(
instance.popperInstance.modifiers.find(m => m.name === 'flip').enabled,
).toBe(false)
})
})

describe('flipBehavior', () => {
Expand Down

0 comments on commit 0489381

Please sign in to comment.