Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to close the dialog box from IHostPageLayoutSercvice #146

Open
AlekhyaYalla opened this issue Jul 10, 2023 · 2 comments
Open

How to close the dialog box from IHostPageLayoutSercvice #146

AlekhyaYalla opened this issue Jul 10, 2023 · 2 comments

Comments

@AlekhyaYalla
Copy link

AlekhyaYalla commented Jul 10, 2023

Hello team,
I'm trying to create a dialog box. Once I have created, how do I close it programmatically?
I'm opening the dialog box with below code.

typescript```

  const dialogSVC: IHostPageLayoutService = await getService<IHostPageLayoutService>(
    CommonServiceIds.HostPageLayoutService
);

     dialogSVC.openMessageDialog(message, {
             lightDismiss: false, showCancel: _showCancel, title: "Codespaces Extension"});


Any method available to close the opened dialog box? 
@karelkral
Copy link

IMO, you cannot close the dialog programmatically. It closes when the user click the button.

@Sahu-Debasish
Copy link

To close the opened dialog box programmatically using the IHostPageLayoutService in a Visual Studio Code extension, you can use the closeDialog method provided by the service. Here's how you can do it:

import { IHostPageLayoutService } from 'vs/workbench/services/host/browser/hostPageLayoutService';
import { CommonServiceIds, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';

// ...

// Get the IHostPageLayoutService
const dialogSVC: IHostPageLayoutService = await getService<IHostPageLayoutService>(
  CommonServiceIds.HostPageLayoutService
);

// Open the dialog
const dialog = dialogSVC.openMessageDialog(message, {
  lightDismiss: false,
  showCancel: _showCancel,
  title: "Codespaces Extension"
});

// Close the dialog programmatically (for example, when a button is clicked)
// You can call this method when you want to close the dialog.
dialog.close();

In the code above, after opening the dialog with dialogSVC.openMessageDialog(), you can use the close() method on the dialog object to close the dialog programmatically. You can call this method when you want to close the dialog, such as when a button is clicked or when a specific condition is met.

This will allow you to control the opening and closing of the dialog box within your extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants