@@ -108,24 +108,30 @@ export const SubMenu = React.forwardRef(function <Tag extends TagType = 'a'>(
108
108
node . style . height = '0px' ;
109
109
refNode . current = node ;
110
110
setIsOpen ( true ) ;
111
- setContextHeight ( {
112
- height : popupRef . current ! . overlayDom . current ! . getBoundingClientRect ( ) . height ,
113
- ele : elementSource . current ! ,
114
- } ) ;
111
+ if ( popupRef . current && popupRef . current . overlayDom . current ) {
112
+ setContextHeight ( {
113
+ height : popupRef . current . overlayDom . current . getBoundingClientRect ( ) . height ,
114
+ ele : elementSource . current ! ,
115
+ } ) ;
116
+ }
115
117
}
116
118
function onEntering ( node : HTMLElement ) {
117
119
node . style . height = `${ node . scrollHeight } px` ;
118
120
}
119
121
function onEntered ( node : HTMLElement ) {
120
122
// node.style.height = 'initial';
121
- node . style . height = popupRef . current ! . overlayDom . current ! . getBoundingClientRect ( ) . height + 'px' ;
123
+ if ( popupRef . current && popupRef . current . overlayDom . current ) {
124
+ node . style . height = popupRef . current . overlayDom . current . getBoundingClientRect ( ) . height + 'px' ;
125
+ }
122
126
}
123
127
function onExiting ( node : HTMLElement ) {
124
128
node . style . height = '0px' ;
125
- setContextHeight ( {
126
- height : - popupRef . current ! . overlayDom . current ! . getBoundingClientRect ( ) . height ,
127
- ele : elementSource . current ! ,
128
- } ) ;
129
+ if ( popupRef . current && popupRef . current . overlayDom . current ) {
130
+ setContextHeight ( {
131
+ height : - popupRef . current ! . overlayDom . current ! . getBoundingClientRect ( ) . height ,
132
+ ele : elementSource . current ! ,
133
+ } ) ;
134
+ }
129
135
}
130
136
function onExit ( node : HTMLElement ) {
131
137
node . style . height = `${ node . scrollHeight } px` ;
@@ -154,7 +160,9 @@ export const SubMenu = React.forwardRef(function <Tag extends TagType = 'a'>(
154
160
menuProps . onClick = onClick ;
155
161
}
156
162
return (
157
- < div
163
+ < li
164
+ data-menu = "subitem"
165
+ ref = { ref }
158
166
onClick = { ( e ) => {
159
167
if ( collapse ) {
160
168
e . stopPropagation ( ) ;
@@ -163,37 +171,35 @@ export const SubMenu = React.forwardRef(function <Tag extends TagType = 'a'>(
163
171
elementSource . current = e . target ;
164
172
} }
165
173
>
166
- < li data-menu = "subitem" ref = { ref } >
167
- < OverlayTrigger
168
- placement = "rightTop"
169
- autoAdjustOverflow
174
+ < OverlayTrigger
175
+ placement = "rightTop"
176
+ autoAdjustOverflow
177
+ disabled = { disabled }
178
+ isOpen = { isOpen }
179
+ usePortal = { false }
180
+ isOutside
181
+ { ...overlayTriggerProps }
182
+ { ...overlayProps }
183
+ ref = { popupRef }
184
+ overlay = { < Menu { ...menuProps } style = { ! collapse ? { paddingLeft : inlineIndent } : { } } /> }
185
+ >
186
+ < MenuItem
187
+ { ...other }
188
+ ref = { null }
170
189
disabled = { disabled }
171
- isOpen = { isOpen }
172
- usePortal = { false }
173
- isOutside
174
- { ...overlayTriggerProps }
175
- { ...overlayProps }
176
- ref = { popupRef }
177
- overlay = { < Menu { ...menuProps } style = { ! collapse ? { paddingLeft : inlineIndent } : { } } /> }
178
- >
179
- < MenuItem
180
- { ...other }
181
- ref = { null }
182
- disabled = { disabled }
183
- isSubMenuItem
184
- addonAfter = { < IconView collapse = { collapse } prefixCls = { prefixCls } isOpen = { isOpen } /> }
185
- className = { [
186
- prefixCls ? `${ prefixCls } -title` : null ,
187
- ! collapse ? `${ prefixCls } -collapse-title` : null ,
188
- className ,
189
- ]
190
- . filter ( Boolean )
191
- . join ( ' ' )
192
- . trim ( ) }
193
- />
194
- </ OverlayTrigger >
195
- </ li >
196
- </ div >
190
+ isSubMenuItem
191
+ addonAfter = { < IconView collapse = { collapse } prefixCls = { prefixCls } isOpen = { isOpen } /> }
192
+ className = { [
193
+ prefixCls ? `${ prefixCls } -title` : null ,
194
+ ! collapse ? `${ prefixCls } -collapse-title` : null ,
195
+ className ,
196
+ ]
197
+ . filter ( Boolean )
198
+ . join ( ' ' )
199
+ . trim ( ) }
200
+ />
201
+ </ OverlayTrigger >
202
+ </ li >
197
203
) ;
198
204
} ) ;
199
205
0 commit comments