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

Fix inputbox onTriggerButton() event #13207

Merged
merged 1 commit into from
Jan 12, 2024

Conversation

tortmayr
Copy link
Contributor

@tortmayr tortmayr commented Dec 22, 2023

What it does

Ensure that the clicked button is correctly forwarded to event handlers when using InputBox.onDidTriggerButton (Plugin API).

The interface definition of QuickInputButtonHandle expects an index property but monaco actually calls the property handle

Fixes #13077

Contributed on behalf of ST Microelectronics

How to test

Create a simple plugin that opens a QuickInputBox with two buttons and log the onDidTriggerButton event.
On master the event is always undefined. With this change the clicked button is correctly forwarded to the event handlers.
e.g:

export async function activate(context: vscode.ExtensionContext) {

		const inputBox = vscode.window.createInputBox();
		const addButton={
			iconPath: new vscode.ThemeIcon('add'),
			tooltip: 'Add Item'
		};
		inputBox.buttons = [vscode.QuickInputButtons.Back, addButton ];
		await new Promise<void>(resolve => {
			inputBox.onDidTriggerButton(event => {
				console.log(event);
			});

			inputBox.onDidAccept(() => {
				resolve();
			});

			inputBox.show();

		});
}

You can also use this example plugin:
quickpick-0.0.1.zip

Follow-ups

Review checklist

Reminder for reviewers

Ensure that the clicked button is correctly forwarded to event handlers when using `InputBox.onDidTriggerButton` (Plugin API).

The  interface definition of `QuickInputButtonHandle` expects an `index` property but monaco actually calls the property `handle`

Fixes  eclipse-theia#13077

Contributed on behalf of ST Microelectronics
Copy link
Contributor

@jfaltermeier jfaltermeier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, lgtm!
I've tested with the attached plugin in electron and browser.

@JonasHelming
Copy link
Contributor

@tortmayr I guess you can merge this!

@tortmayr tortmayr merged commit 78c90dd into eclipse-theia:master Jan 12, 2024
14 checks passed
@jfaltermeier jfaltermeier added this to the 1.46.0 milestone Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

InputBox onDidTriggerButton() events are undefined
3 participants