Skip to content

Commit

Permalink
wip: have trust boundary be selected when label is clicked
Browse files Browse the repository at this point in the history
  • Loading branch information
Tethik committed Jul 2, 2024
1 parent 5539471 commit 0c13894
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/src/components/model/board/shapes/ComponentLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export function ComponentLabel({
stage,
align = "center",
onChange,
onClick,
}) {
const readOnly = useReadOnly();
const nameRef = useRef();
Expand All @@ -37,11 +38,12 @@ export function ComponentLabel({
}
}

function onClick(e) {
function onLocalClick(e) {
if (e.evt.shiftKey || e.evt.ctrlKey || e.evt.metaKey || readOnly) {
return; // Modifier keys are used for multi-select, so we don't want to start editing.
}

onClick && onClick(e);
e.cancelBubble = true; // Prevents the event from bubbling up to component and selecting it, which would cause re-render and loss of focus.
setEditing(true);
editNameRef.current.select();
Expand All @@ -66,7 +68,7 @@ export function ComponentLabel({
x={x}
wrap={"none"}
ellipsis={true}
onClick={onClick}
onClick={onLocalClick}
onMouseEnter={() => {
if (!readOnly) {
document.body.style.cursor = "text";
Expand Down
1 change: 1 addition & 0 deletions app/src/components/model/board/shapes/TrustBoundary.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export function TrustBoundary({
align="left"
type={COMPONENT_TYPE.TRUST_BOUNDARY}
onChange={(name) => setCurrentInputName(name)}
onClick={onClick}
/>

<Indicator x={x + 30} y={y - 8} componentId={id} />
Expand Down

0 comments on commit 0c13894

Please sign in to comment.