Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(vselect): resolve bug in browsers with event order disparity #10620

Merged
merged 1 commit into from
Feb 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions packages/vuetify/src/components/VSelect/VSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,9 @@ export default VTextField.extend({
methods: {
/** @public */
blur (e) {
VTextField.options.methods.blur.call(this, e)
this.isMenuActive = false
this.isFocused = false
this.$refs.input && this.$refs.input.blur()
this.selectedIndex = -1
this.onBlur(e)
},
/** @public */
activateMenu () {
Expand Down Expand Up @@ -530,9 +528,6 @@ export default VTextField.extend({
getValue (item) {
return getPropertyFromItem(item, this.itemValue, this.getText(item))
},
onBlur (e) {
this.$emit('blur', e)
},
onChipInput (item) {
if (this.multiple) this.selectItem(item)
else this.setValue(null)
Expand Down
11 changes: 8 additions & 3 deletions packages/vuetify/src/components/VTextField/VTextField.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,13 @@ export default VInput.extend({
this.onFocus()
},
/** @public */
blur () {
this.$refs.input ? this.$refs.input.blur() : this.onBlur()
blur (e) {
// https://github.com/vuetifyjs/vuetify/issues/5913
// Safari tab order gets broken if called synchronous
window.requestAnimationFrame(() => {
this.$refs.input && this.$refs.input.blur()
})
this.onBlur(e)
},
clearableCallback () {
this.internalValue = null
Expand Down Expand Up @@ -377,7 +382,7 @@ export default VInput.extend({
// to persist
this.internalChange = false

this.$emit('blur', e)
e && this.$emit('blur', e)
},
onClick () {
if (this.isFocused || this.disabled) return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ test('VTextField.js', ({ mount }) => {
expect(change).toHaveBeenCalledTimes(2)
})

it('should have focus and blur methods', () => {
it('should have focus and blur methods', async () => {
const wrapper = mount(VTextField)
const focus = jest.fn()
const blur = jest.fn()
Expand All @@ -756,6 +756,12 @@ test('VTextField.js', ({ mount }) => {
expect(focus).toHaveBeenCalledTimes(1)

wrapper.vm.blur()

// https://github.com/vuetifyjs/vuetify/issues/5913
// Blur waits a requestAnimationFrame
// to resolve a bug in MAC / Safari
await new Promise(resolve => window.requestAnimationFrame(resolve))

expect(blur).toHaveBeenCalledTimes(1)
})

Expand Down