Skip to content
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
2 changes: 2 additions & 0 deletions packages/devextreme/js/__internal/core/m_events_strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,7 @@ export class EventsStrategy {
each(this._events, (eventName, event) => {
event.empty();
});

this._owner = null;
}
}
4 changes: 2 additions & 2 deletions packages/devextreme/js/__internal/core/widget/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ class Widget<
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
const $focusTarget = $element && $element.length ? $element : this._focusTarget();

$focusTarget.toggleClass(FOCUSED_STATE_CLASS, isFocused);
$focusTarget?.toggleClass(FOCUSED_STATE_CLASS, isFocused);
}

_hasFocusClass(element?: dxElementWrapper): boolean {
Expand Down Expand Up @@ -413,7 +413,7 @@ class Widget<
_cleanFocusState(): void {
const $element = this._focusTarget();

$element.removeAttr('tabIndex');
$element?.removeAttr('tabIndex');
this._toggleFocusClass(false);
this._detachFocusEvents();
this._detachKeyboardEvents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ class CollectionWidget<
return shouldSkipRefreshId;
}

_refreshActiveDescendant($target?: dxElementWrapper): void {
_refreshActiveDescendant($target?: dxElementWrapper | null): void {
const { focusedElement } = this.option();

if (isDefined(focusedElement)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,13 @@ class ColorBox extends DropDownEditor<ColorBoxProperties> {
_createColorView(): void {
this._popup.$overlayContent().addClass(COLOR_BOX_OVERLAY_CLASS);

const $colorView = $('<div>').appendTo(this._popup.$content());
const $content = this._popup.$content();

if (!$content) {
return;
}

const $colorView = $('<div>').appendTo($content);

this._colorView = this._createComponent($colorView, ColorView, this._colorViewConfig());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class ContextMenu extends MenuBase {

_itemContainer(): dxElementWrapper {
// @ts-expect-error
return this._overlay ? this._overlay.$content() : $();
return this._overlay?.$content() ?? $();
}

_eventBindingTarget(): dxElementWrapper {
Expand Down Expand Up @@ -425,6 +425,11 @@ class ContextMenu extends MenuBase {

// @ts-expect-error
const $overlayContent = this._overlay.$content();

if (!$overlayContent) {
return;
}

$overlayContent.addClass(DX_CONTEXT_MENU_CLASS);

this._addCustomCssClass($overlayContent);
Expand Down Expand Up @@ -669,7 +674,7 @@ class ContextMenu extends MenuBase {

_getItemsContainers(): dxElementWrapper {
// @ts-expect-error
return this._overlay.$content().find(`.${DX_MENU_ITEMS_CONTAINER_CLASS}`);
return this._overlay?.$content()?.find(`.${DX_MENU_ITEMS_CONTAINER_CLASS}`) ?? $();
}

_searchActiveItem(target): dxElementWrapper {
Expand Down Expand Up @@ -977,7 +982,7 @@ class ContextMenu extends MenuBase {
_hideAllShownSubmenus(): void {
const shownSubmenus = extend([], this._shownSubmenus);
// @ts-expect-error
const $expandedItems = this._overlay.$content().find(`.${DX_MENU_ITEM_EXPANDED_CLASS}`);
const $expandedItems = this._overlay?.$content()?.find(`.${DX_MENU_ITEM_EXPANDED_CLASS}`) ?? $();

$expandedItems.removeClass(DX_MENU_ITEM_EXPANDED_CLASS);

Expand Down Expand Up @@ -1051,8 +1056,7 @@ class ContextMenu extends MenuBase {
if (position) {
if (!this._overlay) {
this._renderContextMenuOverlay();
// @ts-expect-error
this._overlay.$content().addClass(this._widgetClass());
(this._overlay as unknown as Overlay).$content()?.addClass(this._widgetClass());
this._renderFocusState();
this._attachHoverEvents();
this._attachClickEvent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ class DateBox extends DropDownEditor<DateBoxBaseProperties> {

_renderPopup(): void {
super._renderPopup();
this._popup?.$wrapper().addClass(DATEBOX_WRAPPER_CLASS);
this._popup?.$wrapper()?.addClass(DATEBOX_WRAPPER_CLASS);
this._renderPopupWrapper();
}

Expand Down Expand Up @@ -411,7 +411,7 @@ class DateBox extends DropDownEditor<DateBoxBaseProperties> {
const { type } = this.option();

this._popup.$wrapper()
.addClass(`${DATEBOX_WRAPPER_CLASS}-${type}`)
?.addClass(`${DATEBOX_WRAPPER_CLASS}-${type}`)
.addClass(`${DATEBOX_WRAPPER_CLASS}-${this._pickerType}`)
.addClass(DROPDOWNEDITOR_OVERLAY_CLASS);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,19 +161,22 @@ class OverlapStrategy extends DrawerStrategy {
} else if (revealMode === 'expand') {
// @ts-expect-error
this._initialPosition = drawer.isHorizontalDirection() ? { left: 0 } : { top: 0 };
// @ts-expect-error
move($panelOverlayContent, this._initialPosition);

animation.size({
complete: () => {
whenAnimationCompleted.resolve();
},
duration: drawer.option('animationDuration'),
direction: targetPanelPosition,
$element: $panelOverlayContent,
size: panelSize,
marginTop,
});
if ($panelOverlayContent) {
// @ts-expect-error
move($panelOverlayContent, this._initialPosition);

animation.size({
complete: () => {
whenAnimationCompleted?.resolve();
},
duration: drawer.option('animationDuration'),
direction: targetPanelPosition,
$element: $panelOverlayContent,
size: panelSize,
marginTop,
});
}
}
} else if (revealMode === 'slide') {
// @ts-expect-error
Expand All @@ -183,8 +186,10 @@ class OverlapStrategy extends DrawerStrategy {
} else if (revealMode === 'expand') {
// @ts-expect-error
this._initialPosition = drawer.isHorizontalDirection() ? { left: 0 } : { top: 0 };
// @ts-expect-error
move($panelOverlayContent, this._initialPosition);
if ($panelOverlayContent) {
// @ts-expect-error
move($panelOverlayContent, this._initialPosition);
}
// @ts-expect-error
if (drawer.isHorizontalDirection()) {
$($panelOverlayContent).css('width', panelSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,59 @@ export default class DropDownButton extends TextEditorButton {
this.currentTemplate = null;
}

_attachEvents(instance): void {
const { editor } = this;

_attachEvents(instance: Button): void {
instance.option('onClick', (e) => {
// @ts-expect-error
if (editor._shouldCallOpenHandler?.()) {
// @ts-expect-error
editor._openHandler(e);
// @ts-expect-error _shouldCallOpenHandler should be typed
if (this.editor?._shouldCallOpenHandler?.()) {
// @ts-expect-error _openHandler should be typed
this.editor?._openHandler(e);
return;
}
// @ts-expect-error
!editor.option('openOnFieldClick') && editor._openHandler(e);

// @ts-expect-error openOnFieldClick should be typed
const { openOnFieldClick } = this.editor?.option() ?? {};

if (!openOnFieldClick) {
// @ts-expect-error _openHandler should be typed
this.editor?._openHandler(e);
}
});

eventsEngine.on(instance.$element(), 'mousedown', (e) => {
if (editor.$element().is('.dx-state-focused')) {
if (this.editor?.$element()?.is('.dx-state-focused')) {
e.preventDefault();
}
});
}

_create(): {
$element: dxElementWrapper;
instance: Button;
} {
$element: dxElementWrapper;
} | undefined {
const { editor } = this;

if (!editor) {
return undefined;
}

const $element = $('<div>');
const options = this._getOptions();

this._addToContainer($element);

const instance = editor._createComponent($element, Button, extend({}, options, { elementAttr: { 'aria-label': messageLocalization.format(BUTTON_MESSAGE) } }));
const instance = editor._createComponent(
$element,
Button,
extend(
{},
options,
{
elementAttr: {
'aria-label': messageLocalization.format(BUTTON_MESSAGE),
},
},
),
);

this._legacyRender(editor.$element(), $element, options.visible);

Expand All @@ -65,7 +86,7 @@ export default class DropDownButton extends TextEditorButton {
_getOptions() {
const { editor } = this;
const visible = this._isVisible();
const isReadOnly = editor.option('readOnly');
const isReadOnly = editor?.option('readOnly');
const options = {
focusStateEnabled: false,
hoverStateEnabled: false,
Expand All @@ -82,7 +103,7 @@ export default class DropDownButton extends TextEditorButton {
_isVisible(): boolean {
const { editor } = this;
// @ts-expect-error
return super._isVisible() && editor.option('showDropDownButton');
return super._isVisible() && editor?.option('showDropDownButton');
}

// TODO: get rid of it
Expand All @@ -98,13 +119,13 @@ export default class DropDownButton extends TextEditorButton {
}

_isSameTemplate() {
return this.editor.option('dropDownButtonTemplate') === this.currentTemplate;
return this.editor?.option('dropDownButtonTemplate') === this.currentTemplate;
}

_addTemplate(options): void {
if (!this._isSameTemplate()) {
options.template = this.editor._getTemplateByOption('dropDownButtonTemplate');
this.currentTemplate = this.editor.option('dropDownButtonTemplate');
options.template = this.editor?._getTemplateByOption('dropDownButtonTemplate');
this.currentTemplate = this.editor?.option('dropDownButtonTemplate');
}
}

Expand All @@ -114,11 +135,14 @@ export default class DropDownButton extends TextEditorButton {

if (shouldUpdate) {
const { editor, instance } = this;
const $editor = editor.$element();

const $editor = editor?.$element();
const options = this._getOptions();

// @ts-expect-error
instance?.option(options);
this._legacyRender($editor, instance?.$element(), options.visible);

this._legacyRender($editor, (instance as Button)?.$element(), options.visible);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -648,8 +648,8 @@ class DropDownEditor<
});

this._attachPopupKeyHandler();

this._contentReadyHandler();

this._setPopupContentId(this._popup.$content());

this._bindInnerWidgetOptions(this._popup, 'dropDownOptions');
Expand Down Expand Up @@ -690,7 +690,7 @@ class DropDownEditor<
this.close();
}

_setPopupContentId($popupContent: dxElementWrapper): void {
_setPopupContentId($popupContent?: dxElementWrapper | null): void {
this._popupContentId = `dx-${new Guid()}`;
this.setAria('id', this._popupContentId, $popupContent);
}
Expand Down Expand Up @@ -848,14 +848,13 @@ class DropDownEditor<
}

_clean(): void {
delete this._openOnFieldClickAction;
delete this._$templateWrapper;
this._$popup?.remove();

this._openOnFieldClickAction = undefined;
this._$templateWrapper = undefined;
this._popup = undefined;
this._$popup = undefined;

if (this._$popup) {
this._$popup.remove();
delete this._$popup;
delete this._popup;
}
super._clean();
}

Expand Down
24 changes: 16 additions & 8 deletions packages/devextreme/js/__internal/ui/m_action_sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class ActionSheet extends CollectionWidget<Properties> {

_renderPopupTitle(): void {
this._mapPopupOption('showTitle');
this._popup?.$wrapper().toggleClass(ACTION_SHEET_WITHOUT_TITLE_CLASS, !this.option('showTitle'));
this._popup?.$wrapper()?.toggleClass(ACTION_SHEET_WITHOUT_TITLE_CLASS, !this.option('showTitle'));
}

_clean() {
Expand Down Expand Up @@ -169,9 +169,8 @@ class ActionSheet extends CollectionWidget<Properties> {
target: this.option('target'),
}));

this._popup.$overlayContent().attr('role', 'dialog');

this._popup.$wrapper().addClass(ACTION_SHEET_POPOVER_WRAPPER_CLASS);
this._popup.$overlayContent()?.attr('role', 'dialog');
this._popup.$wrapper()?.addClass(ACTION_SHEET_POPOVER_WRAPPER_CLASS);
}

_createPopup(): void {
Expand Down Expand Up @@ -225,11 +224,11 @@ class ActionSheet extends CollectionWidget<Properties> {
},
}));

this._popup.$wrapper().addClass(ACTION_SHEET_POPUP_WRAPPER_CLASS);
this._popup.$wrapper()?.addClass(ACTION_SHEET_POPUP_WRAPPER_CLASS);
}

_popupContentReadyAction(): void {
this._popup.$content().append(this._$itemContainer);
this._popup.$content()?.append(this._$itemContainer);
this._attachClickEvent();
this._attachHoldEvent();

Expand All @@ -250,10 +249,19 @@ class ActionSheet extends CollectionWidget<Properties> {

if (this.option('showCancelButton')) {
const cancelClickAction = this._createActionByOption('onCancelClick') || noop;

const $content = this._popup?.$content();

if (!$content) {
return;
}

const that = this;

this._$cancelButton = $('<div>').addClass(ACTION_SHEET_CANCEL_BUTTON_CLASS)
.appendTo(this._popup?.$content());
this._$cancelButton = $('<div>')
.addClass(ACTION_SHEET_CANCEL_BUTTON_CLASS)
.appendTo($content);

this._createComponent(this._$cancelButton, Button, {
disabled: false,
stylingMode: ACTION_SHEET_BUTTON_DEFAULT_STYLING_MODE,
Expand Down
Loading
Loading