diff --git a/front/src/shared/components/actionsItem.jsx b/front/src/shared/components/actionsItem.jsx index 950c44a7..1470279c 100644 --- a/front/src/shared/components/actionsItem.jsx +++ b/front/src/shared/components/actionsItem.jsx @@ -52,6 +52,7 @@ class ActionsItem extends Component { meta = ( { this.props.onAddAction(action, isCondition); }} @@ -60,7 +61,11 @@ class ActionsItem extends Component { } } else { meta = ( - + ); } let cl = " onFocusAction actionItem"; @@ -79,8 +84,9 @@ class ActionsItem extends Component { this.handleActionsEditableSelected(this.actionsEditableRef, index); }} > + {this.props.toolbox}
{ this.ref = r; }} @@ -145,6 +151,7 @@ ActionsItem.propTypes = { onDeleteActionClick: PropTypes.func, style: PropTypes.shape({}), className: PropTypes.string, + toolbox: PropTypes.node, }; export default ActionsItem; diff --git a/front/src/shared/components/actionsList.jsx b/front/src/shared/components/actionsList.jsx index 2af74fd7..98a587eb 100644 --- a/front/src/shared/components/actionsList.jsx +++ b/front/src/shared/components/actionsList.jsx @@ -71,23 +71,23 @@ class ActionsList extends Component { this.props.onDeleteActionClick(this.props.name, index); }; - updateToolboxDisplay = () => { - if (this.selectedItemRef && this.selectedItemRef.ref && this.toolboxRef) { - const { - left, - top, - width, - } = this.selectedItemRef.ref.parentNode.getBoundingClientRect(); - let adjustedLeft = left - 8; - if (adjustedLeft < 0) { - adjustedLeft = 0; - } - const adjustedTop = top - 36; - const adjustedWidth = width - 2; - const style = `left: ${adjustedLeft}px; top: ${adjustedTop}px; width: ${adjustedWidth}px;`; - this.toolboxRef.style = style; - } - }; + // updateToolboxDisplay = () => { + // if (this.selectedItemRef && this.selectedItemRef.ref && this.toolboxRef) { + // const { + // left, + // top, + // width, + // } = this.selectedItemRef.ref.parentNode.getBoundingClientRect(); + // let adjustedLeft = left - 8; + // if (adjustedLeft < 0) { + // adjustedLeft = 0; + // } + // const adjustedTop = top - 36; + // const adjustedWidth = width - 2; + // const style = `left: ${adjustedLeft}px; top: ${adjustedTop}px; width: ${adjustedWidth}px;`; + // this.toolboxRef.style = style; + // } + // }; render() { const { @@ -108,21 +108,38 @@ class ActionsList extends Component { actions[0].type === "condition"; // const isActionsString = !isActionsEmpty && !isActionsCondition; const editable = true; - let addContentClassname = ""; - let isSelected = false; + + const isInput = name === "input"; + const isIntentOutputEmpty = !isInput && !(actions && actions.length > 0); + const toolbox = ( +
{ + // this.toolboxRef = r; + // this.updateToolboxDisplay(); + // }} + > + +
+ ); + + let addContentClassname = "addActionItem"; + let isAddContentSelected = false; if (this.props.selected === 0) { - addContentClassname = "selectedActionItem"; - isSelected = true; + addContentClassname += " selectedActionItem"; + isAddContentSelected = true; } - const selected = this.props.selected - 1; - addContentClassname = `addActionItem ${addContentClassname}`; const addContent = ( { this.handleAddNewAction(content, isCondition); }} @@ -138,14 +155,15 @@ class ActionsList extends Component { ref={(r) => { if (this.props.selected === 0) { this.selectedItemRef = r; - this.updateToolboxDisplay(); + // this.updateToolboxDisplay(); } }} + toolbox={isAddContentSelected && toolbox} /> ); + const s = { - overflowX: "hidden", - overflowY: "auto", + overflow: "hidden", margin: "0 8px 16px 8px", }; if (actions && actions.length > 0) { @@ -155,7 +173,7 @@ class ActionsList extends Component { contentList = ( {actionsDisplayed.map((action, index) => { - isSelected = isSelected || index === selected; + const selected = index === this.props.selected - 1; return ( { if (index === selected) { this.selectedItemRef = r; - this.updateToolboxDisplay(); + // this.updateToolboxDisplay(); } }} + toolbox={selected && toolbox} /> ); })} @@ -218,34 +237,13 @@ class ActionsList extends Component { />
); - let toolbox = ""; - if (isSelected) { - const isInput = name === "input"; - const isIntentOutputEmpty = !isInput && !(actions && actions.length > 0); - toolbox = ( -
{ - this.toolboxRef = r; - this.updateToolboxDisplay(); - }} - > - -
- ); - } return ( - {toolbox} {addContent} {contentList} diff --git a/front/src/shared/components/actionsToolbox.jsx b/front/src/shared/components/actionsToolbox.jsx index 094be1a5..2a19e98e 100644 --- a/front/src/shared/components/actionsToolbox.jsx +++ b/front/src/shared/components/actionsToolbox.jsx @@ -384,7 +384,7 @@ class ActionsToolbox extends Component {
@@ -388,7 +386,7 @@ exports[`components/actionsList can be rendered with array of actions typed as s @@ -460,7 +458,7 @@ exports[`components/actionsList can be rendered with array of actions typed as s @@ -532,7 +530,7 @@ exports[`components/actionsList can be rendered with array of actions typed as s @@ -604,7 +602,7 @@ exports[`components/actionsList can be rendered with array of actions typed as s @@ -676,7 +674,7 @@ exports[`components/actionsList can be rendered with array of actions typed as s -
  • @@ -868,8 +865,7 @@ exports[`components/actionsList can be rendered with array of actions typed as s style={ Object { "margin": "0 8px 16px 8px", - "overflowX": "hidden", - "overflowY": "auto", + "overflow": "hidden", } } > @@ -883,7 +879,7 @@ exports[`components/actionsList can be rendered with array of actions typed as s
    @@ -935,7 +931,7 @@ exports[`components/actionsList can be rendered with array of actions typed as s
    @@ -1007,7 +1003,7 @@ exports[`components/actionsList can be rendered with array of actions typed as s @@ -1079,7 +1075,7 @@ exports[`components/actionsList can be rendered with array of actions typed as s @@ -1151,7 +1147,7 @@ exports[`components/actionsList can be rendered with array of actions typed as s @@ -1223,7 +1219,7 @@ exports[`components/actionsList can be rendered with array of actions typed as s @@ -1295,7 +1291,7 @@ exports[`components/actionsList can be rendered with array of actions typed as s @@ -1367,7 +1363,7 @@ exports[`components/actionsList can be rendered with array of actions typed as s -
  • @@ -1559,8 +1554,7 @@ exports[`components/actionsList can have an unique id 1`] = ` style={ Object { "margin": "0 8px 16px 8px", - "overflowX": "hidden", - "overflowY": "auto", + "overflow": "hidden", } } /> @@ -1570,7 +1564,7 @@ exports[`components/actionsList can have an unique id 1`] = ` exports[`components/actionsList can have different behavior on action 1`] = `
    -
  • @@ -1745,8 +1738,7 @@ exports[`components/actionsList can have different behavior on action 1`] = ` style={ Object { "margin": "0 8px 16px 8px", - "overflowX": "hidden", - "overflowY": "auto", + "overflow": "hidden", } } /> @@ -1756,7 +1748,7 @@ exports[`components/actionsList can have different behavior on action 1`] = ` exports[`components/actionsList can have different behavior on drop 1`] = `
    -
  • @@ -1931,8 +1922,7 @@ exports[`components/actionsList can have different behavior on drop 1`] = ` style={ Object { "margin": "0 8px 16px 8px", - "overflowX": "hidden", - "overflowY": "auto", + "overflow": "hidden", } } /> @@ -1942,7 +1932,7 @@ exports[`components/actionsList can have different behavior on drop 1`] = ` exports[`components/actionsList can have different behavior on edit 1`] = `
    -
  • @@ -2117,8 +2106,7 @@ exports[`components/actionsList can have different behavior on edit 1`] = ` style={ Object { "margin": "0 8px 16px 8px", - "overflowX": "hidden", - "overflowY": "auto", + "overflow": "hidden", } } /> @@ -2128,7 +2116,7 @@ exports[`components/actionsList can have different behavior on edit 1`] = ` exports[`components/actionsList can have different behavior on select 1`] = `
    -
  • @@ -2303,8 +2290,7 @@ exports[`components/actionsList can have different behavior on select 1`] = ` style={ Object { "margin": "0 8px 16px 8px", - "overflowX": "hidden", - "overflowY": "auto", + "overflow": "hidden", } } /> @@ -2314,7 +2300,7 @@ exports[`components/actionsList can have different behavior on select 1`] = ` exports[`components/actionsList renders correctly 1`] = `
    -
  • @@ -2489,8 +2474,7 @@ exports[`components/actionsList renders correctly 1`] = ` style={ Object { "margin": "0 8px 16px 8px", - "overflowX": "hidden", - "overflowY": "auto", + "overflow": "hidden", } } /> diff --git a/front/tests/shared/components/__snapshots__/intentDetail.test.js.snap b/front/tests/shared/components/__snapshots__/intentDetail.test.js.snap index 7e619987..a8783afb 100644 --- a/front/tests/shared/components/__snapshots__/intentDetail.test.js.snap +++ b/front/tests/shared/components/__snapshots__/intentDetail.test.js.snap @@ -9,7 +9,7 @@ exports[`components/intentDetail can render intent with special characters corre >
    -
  • @@ -184,15 +183,14 @@ exports[`components/intentDetail can render intent with special characters corre style={ Object { "margin": "0 8px 16px 8px", - "overflowX": "hidden", - "overflowY": "auto", + "overflow": "hidden", } } />
    -
  • @@ -373,8 +370,7 @@ exports[`components/intentDetail can render intent with special characters corre style={ Object { "margin": "0 8px 16px 8px", - "overflowX": "hidden", - "overflowY": "auto", + "overflow": "hidden", } } /> @@ -561,7 +557,7 @@ exports[`components/intentDetail renders correctly 1`] = ` >
    -
  • @@ -736,15 +731,14 @@ exports[`components/intentDetail renders correctly 1`] = ` style={ Object { "margin": "0 8px 16px 8px", - "overflowX": "hidden", - "overflowY": "auto", + "overflow": "hidden", } } />
    -
  • @@ -925,8 +918,7 @@ exports[`components/intentDetail renders correctly 1`] = ` style={ Object { "margin": "0 8px 16px 8px", - "overflowX": "hidden", - "overflowY": "auto", + "overflow": "hidden", } } />