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

menu items shouldn't stay selected #901

Closed
howudodat opened this issue Dec 20, 2023 · 2 comments
Closed

menu items shouldn't stay selected #901

howudodat opened this issue Dec 20, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request version 2.x.x Version 2.x.x issues
Milestone

Comments

@howudodat
Copy link

Describe the bug
A simple menu item (ie: file->open) shouldn't stay selected

To Reproduce
run the demo app, simple menu, click on open, then inspect note that the menuitem has dui-menu-item-selected

Expected behavior
unless the menu is a toggle menu type, it shouldn't stay selected

image

@howudodat
Copy link
Author

so in my case I was able to work around this by deselecting the menu item immediately after it getting selected

		.addPlugin(new RowContextMenuPlugin<>(
			Menu.<String>create()
				.appendChild(MenuItem.<String>create("Add Record").withValue("add"))
				.appendChild(MenuItem.<String>create("Delete Record").withValue("delete"))
				.setMultiSelect(false)
				.setContextMenu(true)
				.setDropDirection(new MouseBestFitDirection())
				.apply(self -> self.addSelectionListener((source, selection) -> {
					TableRow<JHomeRatesHistory> tableRow = RowContextMenuMeta.<JHomeRatesHistory>get(self).get().getTableRow();
					source.ifPresent(menuItem -> {
						menuItem.deselect(true);
						switch (menuItem.getValue()) {
							case "add":
								new DlgSpecials(null).open();
								break;
							case "delete":
								MessageBox.YESNO("Do you really want to delete:\n"+tableRow.getRecord().Notes, true, 
									l->onDelete(tableRow.getRecord()),
									l->{});
								break;
						}
						});
				}))))
		;

But in a situation where menu is used for a Select, you want the item "selected". It seems that maybe this will require another MenuItem type, something like ToggleMenuItem or a property toggleEnabled, etc.

@vegegoku vegegoku self-assigned this Jan 14, 2024
@vegegoku vegegoku added the enhancement New feature or request label Jan 14, 2024
@vegegoku vegegoku added this to the 2.0.0 milestone Jan 14, 2024
@vegegoku
Copy link
Member

new method added to the menu setPreserveSelectionStyles(boolean preserveSelectionStyles) to configure this behavior.

@vegegoku vegegoku added the version 2.x.x Version 2.x.x issues label Jan 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request version 2.x.x Version 2.x.x issues
Projects
Status: Done
Development

No branches or pull requests

2 participants