From 1127cef38140ab1eb1cb5220b23dd77f8deca9dd Mon Sep 17 00:00:00 2001 From: Karishma Chadha <kchadha@scratch.mit.edu> Date: Thu, 9 Aug 2018 14:32:57 -0400 Subject: [PATCH] Since the mainTooltpId is now being used as part of the action menu items, make sure it is generated in the constructor of the action menu component instead of within the render method. This fixes a regression caused by a recent change where the file upload buttons in the action menu stopped working. --- src/components/action-menu/action-menu.jsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/components/action-menu/action-menu.jsx b/src/components/action-menu/action-menu.jsx index 90555dfd8..01070b27f 100644 --- a/src/components/action-menu/action-menu.jsx +++ b/src/components/action-menu/action-menu.jsx @@ -24,6 +24,7 @@ class ActionMenu extends React.Component { isOpen: false, forceHide: false }; + this.mainTooltipId = `tooltip-${Math.random()}`; } componentDidMount () { // Touch start on the main button is caught to trigger open and not click @@ -105,8 +106,6 @@ class ActionMenu extends React.Component { onClick } = this.props; - const mainTooltipId = `tooltip-${Math.random()}`; - return ( <div className={classNames(styles.menuContainer, className, { @@ -120,7 +119,7 @@ class ActionMenu extends React.Component { <button aria-label={mainTitle} className={classNames(styles.button, styles.mainButton)} - data-for={mainTooltipId} + data-for={this.mainTooltipId} data-tip={mainTitle} ref={this.setButtonRef} onClick={this.clickDelayer(onClick)} @@ -134,7 +133,7 @@ class ActionMenu extends React.Component { <ReactTooltip className={styles.tooltip} effect="solid" - id={mainTooltipId} + id={this.mainTooltipId} place={tooltipPlace || 'left'} /> <div className={styles.moreButtonsOuter}> @@ -143,7 +142,7 @@ class ActionMenu extends React.Component { fileAccept, fileChange, fileInput}, keyId) => { const isComingSoon = !handleClick; const hasFileInput = fileInput; - const tooltipId = `${mainTooltipId}-${title}`; + const tooltipId = `${this.mainTooltipId}-${title}`; return ( <div key={`${tooltipId}-${keyId}`}> <button -- GitLab