Skip to content

Commit c0496e5

Browse files
authored
fix(Drawer): AllowResize not work (#7365)
* refactor: 兼容嵌套问题 * doc: 更新编码方式 * refactor: 增加 null 检查 * chore: 增加空检查
1 parent 2d06007 commit c0496e5

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/BootstrapBlazor/Components/Drawer/Drawer.razor.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Data from "../../modules/data.js"
1+
import Data from "../../modules/data.js"
22
import Drag from "../../modules/drag.js"
33
import EventHandler from "../../modules/event-handler.js"
44

@@ -9,7 +9,14 @@ const initDrag = el => {
99
let height = 0;
1010
let isVertical = false;
1111
const drawerBody = el.querySelector('.drawer-body');
12-
const bar = el.querySelector('.drawer-bar');
12+
if (drawerBody === null) {
13+
return;
14+
}
15+
const bar = [...drawerBody.children].find(i => i.classList.contains('drawer-bar'));
16+
if (bar === null) {
17+
return;
18+
}
19+
1320
Drag.drag(bar,
1421
e => {
1522
isVertical = drawerBody.classList.contains("top") || drawerBody.classList.contains("bottom")
@@ -105,7 +112,7 @@ export function execute(id, open) {
105112
showDrawer();
106113
}
107114
}
108-
115+
109116
const showDrawer = () => {
110117
drawerBody.classList.add('show');
111118
if (drawerBackdrop) {
@@ -175,8 +182,11 @@ export function dispose(id) {
175182
body.classList.remove('overflow-hidden')
176183
}
177184

178-
const bar = el.querySelector('.drawer-bar');
179-
if (bar) {
180-
Drag.dispose(bar)
185+
const drawerBody = el.querySelector('.drawer-body');
186+
if (drawerBody !== null) {
187+
const bar = [...drawerBody.children].find(i => i.classList.contains('drawer-bar'));
188+
if (bar) {
189+
Drag.dispose(bar)
190+
}
181191
}
182192
}

0 commit comments

Comments
 (0)