Skip to content

Cleanup: what to do with the legacy onClick logic? #3466

Open
@mhsdesign

Description

          > > question is, what to do with the legacy onClick logic?

onClick

handleNodeClick = e => {
const {node, onNodeFocus, onNodeClick, isFocused, reload} = this.props;
const metaKeyPressed = e.metaKey || e.ctrlKey;
const shiftKeyPressed = e.shiftKey;
const altKeyPressed = e.altKey;
// Trigger reload if clicking on the current document node
if (isFocused && reload) {
reload();
}
// Append presetBaseNodeType param to src
const srcWithBaseNodeType = this.props.filterNodeType ? urlWithParams(
$get('uri', node),
{presetBaseNodeType: this.props.filterNodeType}
) : $get('uri', node);
onNodeFocus(node.contextPath, metaKeyPressed, altKeyPressed, shiftKeyPressed);
onNodeClick(srcWithBaseNodeType, node.contextPath, metaKeyPressed, altKeyPressed, shiftKeyPressed);
}

onNodeClick

handleClick = (src, contextPath, metaKeyPressed, altKeyPressed, shiftKeyPressed) => {
const {setActiveContentCanvasSrc, setActiveContentCanvasContextPath, requestScrollIntoView} = this.props;
if (altKeyPressed) {
window.open(window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : '') + window.location.pathname + '?node=' + contextPath);
return;
}
if (metaKeyPressed || shiftKeyPressed) {
return;
}
// Set a flag that will imperatively tell ContentCanvas to scroll to focused node
if (requestScrollIntoView) {
requestScrollIntoView(true);
}
if (setActiveContentCanvasSrc) {
setActiveContentCanvasSrc(src);
}
if (setActiveContentCanvasContextPath) {
setActiveContentCanvasContextPath(contextPath);
}

This logic is still used on a higher layer for the multi operations on nodes. Have tested the feature and made the tests work again.

This legacy second way now introduces a lot of complexity — and we must clean it up please 😅 (or share the logic, comment it and explain how things work and why this would be necessary) otherwise it’s really hard for future people to make sense of the code

This pr is only okay as intermediate step …

Originally posted by @mhsdesign in #3440 (comment)

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions