Skip to content

Commit 7475619

Browse files
authored
fix: update incorrect fullscreen mode focus logic (#3913)
1 parent 5f2d68d commit 7475619

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

‎packages/date-picker/src/vaadin-date-picker-mixin.js‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ export const DatePickerMixin = (subclass) =>
505505
});
506506

507507
// Keep focus attribute in focusElement for styling
508-
this._overlayContent.addEventListener('focus', () => {
508+
this._overlayContent.addEventListener('focusin', () => {
509509
this._setFocused(true);
510510
});
511511

@@ -774,6 +774,7 @@ export const DatePickerMixin = (subclass) =>
774774

775775
if (this._noInput && this.focusElement) {
776776
this.focusElement.blur();
777+
this._overlayContent.focusDateElement();
777778
}
778779
}
779780

@@ -860,11 +861,7 @@ export const DatePickerMixin = (subclass) =>
860861

861862
/** @protected */
862863
_focus() {
863-
if (this._noInput) {
864-
if (this._overlayInitialized) {
865-
this._overlayContent.focus();
866-
}
867-
} else {
864+
if (!this._noInput) {
868865
this.inputElement.focus();
869866
}
870867
}

‎packages/date-picker/test/basic.test.js‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from '@esm-bundle/chai';
2-
import { aTimeout, click, fixtureSync, makeSoloTouchEvent, oneEvent, tap } from '@vaadin/testing-helpers';
2+
import { aTimeout, click, fixtureSync, makeSoloTouchEvent, nextRender, oneEvent, tap } from '@vaadin/testing-helpers';
33
import { sendKeys } from '@web/test-runner-commands';
44
import sinon from 'sinon';
55
import '../src/vaadin-date-picker.js';
@@ -85,6 +85,14 @@ describe('basic features', () => {
8585
expect(datepicker.hasAttribute('focused')).to.be.true;
8686
});
8787

88+
it('should set focused attribute when focused on fullscreen', async () => {
89+
datepicker._fullscreen = true;
90+
datepicker.focus();
91+
await open(datepicker);
92+
await nextRender();
93+
expect(datepicker.hasAttribute('focused')).to.be.true;
94+
});
95+
8896
it('should remove focused attribute when closed and not focused', async () => {
8997
datepicker._fullscreen = true;
9098
datepicker.click();

0 commit comments

Comments
 (0)