diff --git a/lib/components/notification.tsx b/lib/components/notification.tsx index 21510a8e..1b394cc7 100644 --- a/lib/components/notification.tsx +++ b/lib/components/notification.tsx @@ -1,7 +1,10 @@ import React from 'react'; import type {NotificationProps, NotificationState} from '../hyper'; -export default class Notification extends React.PureComponent { +export default class Notification extends React.PureComponent< + React.PropsWithChildren, + NotificationState +> { dismissTimer!: NodeJS.Timeout; constructor(props: NotificationProps) { super(props); diff --git a/lib/components/notifications.tsx b/lib/components/notifications.tsx index f9e71de7..07793949 100644 --- a/lib/components/notifications.tsx +++ b/lib/components/notifications.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, {forwardRef} from 'react'; import {decorate} from '../utils/plugins'; @@ -7,9 +7,9 @@ import type {NotificationsProps} from '../hyper'; const Notification = decorate(Notification_, 'Notification'); -const Notifications: React.FC = (props) => { +const Notifications = forwardRef((props, ref) => { return ( -
+
{props.customChildrenBefore} {props.fontShowing && ( = (props) => { `}
); -}; +}); + +Notifications.displayName = 'Notifications'; export default Notifications; diff --git a/lib/components/searchBox.tsx b/lib/components/searchBox.tsx index b9ff6086..c172584d 100644 --- a/lib/components/searchBox.tsx +++ b/lib/components/searchBox.tsx @@ -1,4 +1,4 @@ -import React, {useCallback, useRef, useEffect} from 'react'; +import React, {useCallback, useRef, useEffect, forwardRef} from 'react'; import type {SearchBoxProps} from '../hyper'; import {VscArrowUp} from '@react-icons/all-files/vsc/VscArrowUp'; import {VscArrowDown} from '@react-icons/all-files/vsc/VscArrowDown'; @@ -82,7 +82,7 @@ const SearchButton = ({ ); }; -const SearchBox = (props: SearchBoxProps) => { +const SearchBox = forwardRef((props, ref) => { const { caseSensitive, wholeWord, @@ -127,7 +127,7 @@ const SearchBox = (props: SearchBoxProps) => { }; return ( -
+
@@ -228,6 +228,8 @@ const SearchBox = (props: SearchBoxProps) => {
); -}; +}); + +SearchBox.displayName = 'SearchBox'; export default SearchBox; diff --git a/lib/components/split-pane.tsx b/lib/components/split-pane.tsx index 0b979755..9c67d413 100644 --- a/lib/components/split-pane.tsx +++ b/lib/components/split-pane.tsx @@ -2,7 +2,10 @@ import React from 'react'; import sum from 'lodash/sum'; import type {SplitPaneProps} from '../hyper'; -export default class SplitPane extends React.PureComponent { +export default class SplitPane extends React.PureComponent< + React.PropsWithChildren, + {dragging: boolean} +> { dragPanePosition!: number; dragTarget!: Element; panes!: Element[]; diff --git a/lib/components/style-sheet.tsx b/lib/components/style-sheet.tsx index f8079740..0c9ef4bb 100644 --- a/lib/components/style-sheet.tsx +++ b/lib/components/style-sheet.tsx @@ -1,11 +1,11 @@ -import React from 'react'; +import React, {forwardRef} from 'react'; import type {StyleSheetProps} from '../hyper'; -const StyleSheet: React.FC = (props) => { +const StyleSheet: React.FC = forwardRef((props, ref) => { const {borderColor} = props; return ( - ); -}; +}); + +StyleSheet.displayName = 'StyleSheet'; export default StyleSheet; diff --git a/lib/components/tab.tsx b/lib/components/tab.tsx index 6c9ded50..5c4c1329 100644 --- a/lib/components/tab.tsx +++ b/lib/components/tab.tsx @@ -1,7 +1,7 @@ -import React from 'react'; +import React, {forwardRef} from 'react'; import type {TabProps} from '../hyper'; -const Tab = (props: TabProps) => { +const Tab = forwardRef((props, ref) => { const handleClick = (event: React.MouseEvent) => { const isLeftClick = event.nativeEvent.which === 1; @@ -28,6 +28,7 @@ const Tab = (props: TabProps) => { className={`tab_tab ${isFirst ? 'tab_first' : ''} ${isActive ? 'tab_active' : ''} ${ isFirst && isActive ? 'tab_firstActive' : '' } ${hasActivity ? 'tab_hasActivity' : ''}`} + ref={ref} > {props.customChildrenBefore} { `} ); -}; +}); + +Tab.displayName = 'Tab'; export default Tab; diff --git a/lib/components/tabs.tsx b/lib/components/tabs.tsx index 60a1ecd5..e966b317 100644 --- a/lib/components/tabs.tsx +++ b/lib/components/tabs.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, {forwardRef} from 'react'; import {decorate, getTabProps} from '../utils/plugins'; @@ -9,13 +9,13 @@ import DropdownButton from './new-tab'; const Tab = decorate(Tab_, 'Tab'); const isMac = /Mac/.test(navigator.userAgent); -const Tabs = (props: TabsProps) => { +const Tabs = forwardRef((props, ref) => { const {tabs = [], borderColor, onChange, onClose, fullScreen} = props; const hide = !isMac && tabs.length === 1; return ( -