window.showDirectoryPicker() not allowed error file picker already active

const btn = document.getElementById('btn');
const pre = document.getElementById('pre');

btn.addEventListener('click', async (e) => {

  try {
      const dirHandle = await window.showDirectoryPicker();

      pre.innerHTML = `${dirHandle.name}`;

    } 
  catch (error) {       
      console.log(error);      
    }

  });

When I click “Open” without selecting any directory and close the window, and after this , when I click the button again (btn), it gives “file already active” every time and does not open the directory window. Any solutions?