Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions apps/client/src/widgets/ribbon/components/AttributeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ export default function AttributeEditor({ api, note, componentId, notePath, ntxI
const [ state, setState ] = useState<"normal" | "showHelpTooltip" | "showAttributeDetail">();
const [ error, setError ] = useState<unknown>();
const [ needsSaving, setNeedsSaving ] = useState(false);
const [isMenuOpen, setIsMenuOpen] = useState(false);
const suppressNextOnHide = useRef(false);

const lastSavedContent = useRef<string>();
const currentValueRef = useRef(currentValue);
Expand Down Expand Up @@ -383,6 +385,12 @@ export default function AttributeEditor({ api, note, componentId, notePath, ntxI
onClick={(e) => {
// Prevent automatic hiding of the context menu due to the button being clicked.
e.stopPropagation();
if (isMenuOpen) {
// If we re-show the menu, ContextMenu.show() will call hide()
// and immediately trigger onHide. Suppress that transient hide.
suppressNextOnHide.current = true;
}
setIsMenuOpen(true);

contextMenu.show<AttributeCommandNames>({
x: e.pageX,
Expand All @@ -395,7 +403,14 @@ export default function AttributeEditor({ api, note, componentId, notePath, ntxI
{ title: t("attribute_editor.add_new_label_definition"), command: "addNewLabelDefinition", uiIcon: "bx bx-empty" },
{ title: t("attribute_editor.add_new_relation_definition"), command: "addNewRelationDefinition", uiIcon: "bx bx-empty" }
],
selectMenuItemHandler: (item) => handleAddNewAttributeCommand(item.command)
selectMenuItemHandler: (item) => handleAddNewAttributeCommand(item.command),
onHide: () => {
if (suppressNextOnHide.current) {
suppressNextOnHide.current = false;
return;
}
setIsMenuOpen(false);
},
});
}}
/>
Expand Down Expand Up @@ -438,4 +453,4 @@ function getClickIndex(pos: ModelPosition) {
}

return clickIndex;
}
}
Loading