Skip to content

Commit cdd8752

Browse files
author
marker dao ®
committed
fix
1 parent e3f7a0e commit cdd8752

File tree

7 files changed

+35
-26
lines changed

7 files changed

+35
-26
lines changed

packages/devextreme/js/__internal/core/widget/widget.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ class Widget<
336336
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
337337
const $focusTarget = $element && $element.length ? $element : this._focusTarget();
338338

339-
$focusTarget.toggleClass(FOCUSED_STATE_CLASS, isFocused);
339+
$focusTarget?.toggleClass(FOCUSED_STATE_CLASS, isFocused);
340340
}
341341

342342
_hasFocusClass(element?: dxElementWrapper): boolean {
@@ -413,7 +413,7 @@ class Widget<
413413
_cleanFocusState(): void {
414414
const $element = this._focusTarget();
415415

416-
$element.removeAttr('tabIndex');
416+
$element?.removeAttr('tabIndex');
417417
this._toggleFocusClass(false);
418418
this._detachFocusEvents();
419419
this._detachKeyboardEvents();

packages/devextreme/js/__internal/ui/collection/collection_widget.base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ class CollectionWidget<
558558
return shouldSkipRefreshId;
559559
}
560560

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

564564
if (isDefined(focusedElement)) {

packages/devextreme/js/__internal/ui/context_menu/m_context_menu.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ class ContextMenu extends MenuBase {
181181

182182
_itemContainer(): dxElementWrapper {
183183
// @ts-expect-error
184-
return this._overlay ? this._overlay.$content() : $();
184+
return this._overlay?.$content() ?? $();
185185
}
186186

187187
_eventBindingTarget(): dxElementWrapper {
@@ -425,6 +425,11 @@ class ContextMenu extends MenuBase {
425425

426426
// @ts-expect-error
427427
const $overlayContent = this._overlay.$content();
428+
429+
if (!$overlayContent) {
430+
return;
431+
}
432+
428433
$overlayContent.addClass(DX_CONTEXT_MENU_CLASS);
429434

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

670675
_getItemsContainers(): dxElementWrapper {
671676
// @ts-expect-error
672-
return this._overlay.$content().find(`.${DX_MENU_ITEMS_CONTAINER_CLASS}`);
677+
return this._overlay?.$content()?.find(`.${DX_MENU_ITEMS_CONTAINER_CLASS}`) ?? $();
673678
}
674679

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

982987
$expandedItems.removeClass(DX_MENU_ITEM_EXPANDED_CLASS);
983988

@@ -1051,8 +1056,7 @@ class ContextMenu extends MenuBase {
10511056
if (position) {
10521057
if (!this._overlay) {
10531058
this._renderContextMenuOverlay();
1054-
// @ts-expect-error
1055-
this._overlay.$content().addClass(this._widgetClass());
1059+
(this._overlay as unknown as Overlay).$content()?.addClass(this._widgetClass());
10561060
this._renderFocusState();
10571061
this._attachHoverEvents();
10581062
this._attachClickEvent();

packages/devextreme/js/__internal/ui/drawer/m_drawer.rendering.strategy.overlap.ts

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -161,19 +161,22 @@ class OverlapStrategy extends DrawerStrategy {
161161
} else if (revealMode === 'expand') {
162162
// @ts-expect-error
163163
this._initialPosition = drawer.isHorizontalDirection() ? { left: 0 } : { top: 0 };
164-
// @ts-expect-error
165-
move($panelOverlayContent, this._initialPosition);
166164

167-
animation.size({
168-
complete: () => {
169-
whenAnimationCompleted.resolve();
170-
},
171-
duration: drawer.option('animationDuration'),
172-
direction: targetPanelPosition,
173-
$element: $panelOverlayContent,
174-
size: panelSize,
175-
marginTop,
176-
});
165+
if ($panelOverlayContent) {
166+
// @ts-expect-error
167+
move($panelOverlayContent, this._initialPosition);
168+
169+
animation.size({
170+
complete: () => {
171+
whenAnimationCompleted?.resolve();
172+
},
173+
duration: drawer.option('animationDuration'),
174+
direction: targetPanelPosition,
175+
$element: $panelOverlayContent,
176+
size: panelSize,
177+
marginTop,
178+
});
179+
}
177180
}
178181
} else if (revealMode === 'slide') {
179182
// @ts-expect-error
@@ -183,8 +186,10 @@ class OverlapStrategy extends DrawerStrategy {
183186
} else if (revealMode === 'expand') {
184187
// @ts-expect-error
185188
this._initialPosition = drawer.isHorizontalDirection() ? { left: 0 } : { top: 0 };
186-
// @ts-expect-error
187-
move($panelOverlayContent, this._initialPosition);
189+
if ($panelOverlayContent) {
190+
// @ts-expect-error
191+
move($panelOverlayContent, this._initialPosition);
192+
}
188193
// @ts-expect-error
189194
if (drawer.isHorizontalDirection()) {
190195
$($panelOverlayContent).css('width', panelSize);

packages/devextreme/js/__internal/ui/drop_down_editor/m_drop_down_button.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default class DropDownButton extends TextEditorButton {
2121
this.currentTemplate = null;
2222
}
2323

24-
_attachEvents(instance): void {
24+
_attachEvents(instance: Button): void {
2525
instance.option('onClick', (e) => {
2626
// @ts-expect-error _shouldCallOpenHandler should be typed
2727
if (this.editor?._shouldCallOpenHandler?.()) {

packages/devextreme/js/ui/diagram/ui.diagram.dialogs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ class DiagramDialog extends Widget {
101101
}
102102
_show() {
103103
this._popup
104-
.$content()
105-
.empty()
104+
?.$content()
105+
?.empty()
106106
.append(this._onGetContentAction());
107107
this._popup.show();
108108
this._isShown = true;

packages/devextreme/js/ui/file_manager/ui.file_manager.notification.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ export default class FileManagerNotificationControl extends Widget {
239239
if(this._isProgressDrawerOpened() || !this.option('showNotificationPopup')) {
240240
return;
241241
}
242-
this._getNotificationPopup().$wrapper().toggleClass(FILE_MANAGER_NOTIFICATION_POPUP_ERROR_CLASS, !!errorMode);
242+
this._getNotificationPopup().$wrapper()?.toggleClass(FILE_MANAGER_NOTIFICATION_POPUP_ERROR_CLASS, !!errorMode);
243243
this._getNotificationPopup().option('contentTemplate', content);
244244
if(!this._getNotificationPopup().option('visible')) {
245245
this._getNotificationPopup().show();

0 commit comments

Comments
 (0)