Something strange happening with UXP document color mode

If I run the code below and create a new document in RGBColorMode, then click on Image>>Mode, there’s a check next to submenu item “RGB Color”. All well and good. However, if I then run the code, but change the dropdown so it generates a new document in CMYKColorMode, the tab for the document displays something like "Untitled-X @ 25% (CMYK/8), but when I click on Image>>Mode, there’s still a check next to submenu item “RGB Color”.

async function createNewDocumentAndCanvas(executionContext, descriptor) {
    const app = require("photoshop").app;
	let cMode = document.getElementById("dropVendor").selectedIndex == 0 ? "RGBColorMode" : "CMYKColorMode";
	let newDoc = await app.documents.add({
	   width: descriptor.canvasWpx, 
	   height: descriptor.canvasHpx, 
	   resolution: descriptor.resDpi, 
	   mode: cMode,	//"RGBColorMode", "CMYKColorMode"
	   fill: "black"		//"transparent", "black", "white"
	addGuidesToDocument(newDoc, descriptor);
	return newDoc;

It took me a while but I think I figured it out: if I click on another document tab to change documents, then come back to this document, the Image>>Mode submenu item now shows a click next to “CMYK Color”, which is correct. I think the UXP engine is simply not updating the menu item when it creates the new document, but the menu item is getting updated by the main UI when a document tab is clicked. Wasted a lot of time thinking “app.documents.add({…” was not setting the color mode correctly.