File tree Expand file tree Collapse file tree 1 file changed +15
-11
lines changed Expand file tree Collapse file tree 1 file changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -216,23 +216,14 @@ class MasterbarItem extends Component< MasterbarItemProps > {
216
216
disabled : this . props . disabled ,
217
217
} ;
218
218
219
- const MenuItem = ( props : React . HTMLAttributes < HTMLElement > ) =>
220
- this . props . url ? (
221
- < a
222
- href = { this . props . url }
223
- ref = { this . props . innerRef as LegacyRef < HTMLAnchorElement > }
224
- { ...props }
225
- />
226
- ) : (
227
- < button ref = { this . props . innerRef as LegacyRef < HTMLButtonElement > } { ...props } />
228
- ) ;
229
-
230
219
return (
231
220
< div
232
221
className = { clsx ( 'masterbar__item-wrapper' , this . props . wrapperClassName ) }
233
222
ref = { this . wrapperRef }
234
223
>
235
224
< MenuItem
225
+ url = { this . props . url }
226
+ innerRef = { this . props . innerRef }
236
227
{ ...attributes }
237
228
onKeyDown = { this . props . subItems && this . toggleMenuByKey }
238
229
onTouchEnd = { this . props . subItems && this . toggleMenuByTouch }
@@ -248,3 +239,16 @@ class MasterbarItem extends Component< MasterbarItemProps > {
248
239
export default forwardRef < HTMLButtonElement | HTMLAnchorElement , MasterbarItemProps > (
249
240
( props , ref ) => < MasterbarItem innerRef = { ref } { ...props } />
250
241
) ;
242
+
243
+ type MenuItemProps < R > = {
244
+ url ?: string ;
245
+ innerRef ?: R ;
246
+ } & React . HTMLAttributes < HTMLElement > ;
247
+
248
+ function MenuItem < R > ( { url, innerRef, ...props } : MenuItemProps < R > ) {
249
+ return url ? (
250
+ < a href = { url } ref = { innerRef as LegacyRef < HTMLAnchorElement > } { ...props } />
251
+ ) : (
252
+ < button ref = { innerRef as LegacyRef < HTMLButtonElement > } { ...props } />
253
+ ) ;
254
+ }
You can’t perform that action at this time.
0 commit comments