diff --git a/packages/xod-client/src/core/domSideeffectsMiddleware.js b/packages/xod-client/src/core/domSideeffectsMiddleware.js index d6685f2fb..c3175bf1b 100644 --- a/packages/xod-client/src/core/domSideeffectsMiddleware.js +++ b/packages/xod-client/src/core/domSideeffectsMiddleware.js @@ -1,19 +1,22 @@ import waitForElement from 'wait-for-element'; -import { FOCUS_BOUND_VALUE } from '../editor/actionTypes'; +import { FOCUS_BOUND_VALUE, FOCUS_LABEL } from '../editor/actionTypes'; + +const CONTROL_SELECTORS = { + // Select widget control with a tricky selector instead of ID, because + // some constant nodes has a generated id of the terminal Node + [FOCUS_BOUND_VALUE]: '.PinWidget input, .PinWidget select', + [FOCUS_LABEL]: '#widget_label', +}; export default _ => next => action => { - if (action.type === FOCUS_BOUND_VALUE) { + if (Object.prototype.hasOwnProperty.call(CONTROL_SELECTORS, action.type)) { // First of all, do the stuff in reducers to show inspector pane. const n = next(action); // Wait for updated Inspector, because it could appeared // or it changed entirely on new selection waitForElement('.Inspector-container') .then(__ => { - // Select widget control with a tricky selector instead of ID, because - // some constant nodes has a generated id of the terminal Node - const ctrl = document.querySelector( - '.PinWidget input, .PinWidget select' - ); + const ctrl = document.querySelector(CONTROL_SELECTORS[action.type]); if (!ctrl) return; if (ctrl.setSelectionRange) ctrl.setSelectionRange(0, ctrl.value.length); diff --git a/packages/xod-client/src/editor/actionTypes.js b/packages/xod-client/src/editor/actionTypes.js index 998487baf..47513d3b7 100644 --- a/packages/xod-client/src/editor/actionTypes.js +++ b/packages/xod-client/src/editor/actionTypes.js @@ -47,6 +47,7 @@ export const MOVE_PANEL = 'MOVE_PANEL'; export const TOGGLE_PANEL_AUTOHIDE = 'TOGGLE_PANEL_AUTOHIDE'; export const FOCUS_BOUND_VALUE = 'FOCUS_BOUND_VALUE'; +export const FOCUS_LABEL = 'FOCUS_LABEL'; export const TABTEST_RUN_REQUESTED = 'TABTEST_RUN_REQUESTED'; export const TABTEST_GENERATED_CPP = 'TABTEST_GENERATED_CPP'; diff --git a/packages/xod-client/src/editor/actions.js b/packages/xod-client/src/editor/actions.js index a0d618fc2..44f170061 100644 --- a/packages/xod-client/src/editor/actions.js +++ b/packages/xod-client/src/editor/actions.js @@ -714,6 +714,14 @@ export const focusBoundValue = (nodeId, patchPath) => ({ }, }); +export const focusLabel = (nodeId, patchPath) => ({ + type: ActionType.FOCUS_LABEL, + payload: { + nodeId, + patchPath, + }, +}); + export const abortTabtest = () => (dispatch, getState) => { const worker = Selectors.tabtestWorker(getState()); if (worker) worker.terminate(); diff --git a/packages/xod-client/src/editor/containers/Patch/index.jsx b/packages/xod-client/src/editor/containers/Patch/index.jsx index d40fe1e01..45e900411 100644 --- a/packages/xod-client/src/editor/containers/Patch/index.jsx +++ b/packages/xod-client/src/editor/containers/Patch/index.jsx @@ -378,6 +378,7 @@ const mapDispatchToProps = dispatch => ({ splitLinksToBuses: EditorActions.splitLinksToBuses, addBusNode: ProjectActions.addBusNode, focusBoundValue: EditorActions.focusBoundValue, + focusLabel: EditorActions.focusLabel, }, dispatch ), diff --git a/packages/xod-client/src/editor/containers/Patch/modes/debugging.jsx b/packages/xod-client/src/editor/containers/Patch/modes/debugging.jsx index 133f3c990..164b8e011 100644 --- a/packages/xod-client/src/editor/containers/Patch/modes/debugging.jsx +++ b/packages/xod-client/src/editor/containers/Patch/modes/debugging.jsx @@ -14,10 +14,19 @@ import { bindApi, getOffsetMatrix } from '../modeUtils'; const debuggingMode = R.merge(selectingMode, { onNodeDoubleClick(api, nodeId, patchPath) { - if (patchPath === XP.NOT_IMPLEMENTED_IN_XOD_PATH) { - api.props.actions.openImplementationEditor(); - } else if (XP.isConstantNodeType(patchPath) || XP.isTweakPath(patchPath)) { + if (R.contains(patchPath, R.keys(XP.MANAGED_ATTACHMENT_FILENAMES))) { + api.props.actions.openAttachmentEditor(patchPath); + } else if ( + XP.isConstantNodeType(patchPath) || + XP.isTweakPath(patchPath) || + XP.isBindableCustomType(patchPath) + ) { api.props.actions.focusBoundValue(nodeId, api.props.patchPath); + } else if ( + XP.isBusPatchPath(patchPath) || + XP.isTerminalPatchPath(patchPath) + ) { + api.props.actions.focusLabel(nodeId, api.props.patchPath); } else { api.props.actions.drillDown(patchPath, nodeId); } diff --git a/packages/xod-client/src/editor/containers/Patch/modes/selecting.jsx b/packages/xod-client/src/editor/containers/Patch/modes/selecting.jsx index d0c9d29a9..550e5faa7 100644 --- a/packages/xod-client/src/editor/containers/Patch/modes/selecting.jsx +++ b/packages/xod-client/src/editor/containers/Patch/modes/selecting.jsx @@ -237,6 +237,11 @@ const selectingMode = { XP.isBindableCustomType(patchPath) ) { api.props.actions.focusBoundValue(nodeId, api.props.patchPath); + } else if ( + XP.isBusPatchPath(patchPath) || + XP.isTerminalPatchPath(patchPath) + ) { + api.props.actions.focusLabel(nodeId, api.props.patchPath); } else { api.props.actions.switchPatch(patchPath); } diff --git a/packages/xod-client/src/editor/reducer.js b/packages/xod-client/src/editor/reducer.js index 4833aaeb0..d5b587b41 100644 --- a/packages/xod-client/src/editor/reducer.js +++ b/packages/xod-client/src/editor/reducer.js @@ -633,6 +633,7 @@ const editorReducer = (state = initialState, action) => { ); case EAT.FOCUS_BOUND_VALUE: + case EAT.FOCUS_LABEL: // maximize Inspector panel to focus & select widget's input return R.assocPath( ['panels', PANEL_IDS.INSPECTOR, 'maximized'],