Skip to content

Commit

Permalink
EditDialog: Open new tab with cmd click (#887)
Browse files Browse the repository at this point in the history
  • Loading branch information
jvaclavik authored Jan 11, 2025
1 parent 32a17aa commit 6149a48
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const MembersEditor = () => {
key={member.shortId}
shortId={member.shortId}
label={member.label}
onClick={() => handleClick(member.shortId)}
onClick={(e) => handleClick(e, member.shortId)}
/>
);
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const ParentsEditor = () => {
key={shortId}
shortId={shortId}
label={parent.tags.name}
onClick={() => handleClick(shortId)}
onClick={(e) => handleClick(e, shortId)}
/>
);
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,21 @@ const isInItems = (items: Array<EditDataItem>, shortId: string) =>
export const useGetHandleClick = () => {
const { addFeature, items, setCurrent } = useEditContext();

return async (shortId: string) => {
return async (e, shortId: string) => {
const isCmdClicked = e.ctrlKey || e.metaKey;
const apiId = getApiId(shortId);
if (apiId.id < 0) {
setCurrent(shortId);
if (!isCmdClicked) setCurrent(shortId);
return;
}

if (isInItems(items, shortId)) {
setCurrent(shortId);
if (!isCmdClicked) setCurrent(shortId);
return;
}

const feature = await getFullFeatureWithMemberFeatures(apiId);
addFeature(feature);
setCurrent(getShortId(feature.osmMeta));
if (!isCmdClicked) setCurrent(getShortId(feature.osmMeta));
};
};

0 comments on commit 6149a48

Please sign in to comment.