Browse Source

add switchTabHandler to check null

kaoritokashiki 5 years ago
parent
commit
51b5b08bfb

+ 8 - 0
src/client/js/components/PageAccessoriesModal.jsx

@@ -25,12 +25,20 @@ const PageAccessoriesModal = (props) => {
     props.onClose();
   }
 
+  function switchTabHandler() {
+    if (props.onSwitch == null) {
+      return;
+    }
+    props.onSwitch();
+  }
+
   return (
     <React.Fragment>
       <Modal
         size="lg"
         isOpen={props.isOpen}
         toggle={closeModalHandler}
+        toggleSwitch={switchTabHandler}
         className="grw-page-accessories-modal"
       >
         <ModalBody>

+ 0 - 5
src/client/js/components/TopOfTableContents.jsx

@@ -15,7 +15,6 @@ import PageAccessoriesModal from './PageAccessoriesModal';
 import { withUnstatedContainers } from './UnstatedUtils';
 
 const TopOfTableContents = (props) => {
-  const { onSwitch } = props;
 
   const [isPageAccessoriesModalShown, setIsPageAccessoriesModalShown] = useState(false);
   const [activeTab, setActiveTab] = useState('');
@@ -28,9 +27,6 @@ const TopOfTableContents = (props) => {
   }
 
   function switchActiveTab(clickedTab) {
-    if (onSwitch == null) {
-      return;
-    }
     activeComponents.add(clickedTab);
     setActiveComponents(activeComponents);
     setActiveTab(clickedTab);
@@ -90,7 +86,6 @@ const TopOfTableContentsWrapper = withUnstatedContainers(TopOfTableContents, [Pa
 
 TopOfTableContents.propTypes = {
   pageContainer: PropTypes.instanceOf(PageContainer).isRequired,
-  onSwitch: PropTypes.func,
 };
 
 export default withTranslation()(TopOfTableContentsWrapper);