How to disable plugin functionality while performing external actions

I created a test plugin and I want to know how to disable the plugin functionality when the user press a plugin button to which performs other actions, e.g. browse for a file, select a color etc.
I don’t want to allow the user to press, e.g. “duplicate file” when the browse for file for is open.

E.g. I use this function to browse for a folder:

 async function openBrowsButton() {
   const fs = require('uxp').storage.localFileSystem;
   const userFolder = await fs.getFolder();  // folder picker
   fullPath = userFolder.nativePath;
   return fullPath;
 }

Have you tried wrapping your code in the

require('photoshop').core.executeAsModal;

functionality?

That should put Ps in a modal state until your code completes, I think, which would prevent other plugin buttons from functioning.

Haven’t tried this, but might be worth trying.

Documentation here.

Yes but i must be missing something.

Here I add teh event listener to the button:
$("#btnBrowse").click(function(){browseForFile(this.id);});

Here I call the brows function:

async function browseForFile(id){
  await require("photoshop").core.executeAsModal(async (executionControl, descriptor) => {
    // $('#' + id).prop('disabled', true)
  // document.getElementById(id).disabled = true;
  fullPath = await openBrowsButton();
  $("#fileRoot").val(fullPath);
  storeLocalVal("fileRoot")
  // $('#' + id).prop('disabled', true)
});
}

Ans this is th actual brows function:

async function openBrowsButton() {
   const fs = require('uxp').storage.localFileSystem;
   let userFolder = await fs.getFolder();  // folder picker
   fullPath = userFolder.nativePath;
   return fullPath;
}

What should I change in this structure to ‘disable’ PS while browsing?