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

DropDownEditor: Detach focus events before attaching new ones (T1238121) #28547

Open
wants to merge 3 commits into
base: 24_2
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ const DropDownEditor = TextBox.inherit({
},

_render() {
this._detachFocusEvents();

this.callBase();

this._renderOpenHandler();
Expand Down Expand Up @@ -291,7 +293,9 @@ const DropDownEditor = TextBox.inherit({
_renderField() {
const fieldTemplate = this._getFieldTemplate();

fieldTemplate && this._renderTemplatedField(fieldTemplate, this._fieldRenderData());
if (fieldTemplate) {
this._renderTemplatedField(fieldTemplate, this._fieldRenderData());
}
},

_renderPlaceholder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,11 @@ const TextEditorBase = Editor.inherit({
this._renderStylingMode();
this._renderInputType();
this._renderPlaceholder();

this._renderProps();

this.callBase();

this._renderValue();

this._renderLabel();
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,29 @@ QUnit.module('focus policy', () => {
assert.ok($dropDownEditor.hasClass('dx-state-focused'), 'Widget is focused after click on clearButton');
});

[
{ eventName: 'onFocusIn', scenario: 'focus' },
{ eventName: 'onFocusOut', scenario: 'blur ' },
].forEach(({ eventName, scenario }) => {
QUnit.test(`${eventName} should be called only once on component ${scenario} when fieldTemplate is specified (T1238121)`, function(assert) {
const eventStub = sinon.stub();

const dropDownEditor = $('#dropDownEditorLazy').dxDropDownEditor({
[eventName]: eventStub,
fieldTemplate(_, container) {
$('<div>').dxTextBox({
readOnly: true,
}).appendTo(container);
},
}).dxDropDownEditor('instance');

dropDownEditor.focus();
dropDownEditor.blur();

assert.strictEqual(eventStub.callCount, 1, `${eventName} called once`);
});
});

QUnit.testInActiveWindow('input is focused by click on dropDownButton', function(assert) {
const $dropDownEditor = $('#dropDownEditorLazy').dxDropDownEditor({
focusStateEnabled: true
Expand Down
Loading