Accessing the close tab and close button in the uxp plugin

Hello I am trying to find out if there is an event listener when user closes the uxp plugin and photoshop so that I can run some code when that happens.


I tried to find some examples in the forum but haven’t succeed yet.
Can I access it via entrypoints for uxp?

import { entrypoints } from 'uxp';

For closing photoshop I tried this:

require('photoshop').action.addNotificationListener([{ event: 'close' }], event => {
  if (event === 'close') {
    showDialog('bye bye');

Thanks in advance!

For plugin panels check Entry Points docs (specfically entrypoints.panels[].show and entrypoints.panels[].hide). But know, that these callbacks were documented for a while now, but they never worked. Maybe they do now - you’ll need to check

1 Like

is this what you’re looking for?

document.addEventListener('uxpcommand', (event) => {
   const { commandId } = event
   if (commandId === 'uxpshowpanel') {
     console.log("panel is showing");
   } else if (commandId === 'uxphidepanel') {
     console.log('panel is hiding');

@Karmalakas Thanks I will have a look!

@Maher thanks a lot for the example. I will try and share results soon!

@Maher I tested and the debugger showed the console.log once I closed the plugin! Thanks!