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

DataTable - Stop mouse events from bubbling if in edit mode #892

Closed
howudodat opened this issue Nov 27, 2023 · 2 comments
Closed

DataTable - Stop mouse events from bubbling if in edit mode #892

howudodat opened this issue Nov 27, 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
When a DataTable row is in edit mode events from the editors are bubbled up to the table. This creates a situation where using RowClick plugin and DoubleClick plugin will then receive events when the row is in edit mode.

To Reproduce
Use code below.

  1. click on a row (enables edit) and then click in a textbox, (disables edit)
  2. switch to DoubleClick plugin, repeat step 1 but with double clicks

Expected behavior
it seems to me that if a row is in edit mode that events would be blocked from bubbling up

	protected AppLayout layout = AppLayout.create("Domino-ui test");
	public static DateTimeFormat sdfLongMs = DateTimeFormat.getFormat("MM/dd/yyyy HH:mm:ss.SSS");

	class Record {
		public Record(int id, String name) { this.id = id; this.name = name; }
		int id;
		String name;
	}

	protected LocalListDataStore<Record> ds = new LocalListDataStore<>();


	/**
	 * This is the entry point method.
	 */
	public void onModuleLoad() {
		layout.withContent((parent1, content) -> {
			content.appendChild(createTable());
		});

		body().appendChild(layout);
	}

	protected DataTable<Record> createTable() {
		TableConfig<Record> tableConfig = new TableConfig<>();
		tableConfig
				.setFixed(true)
				.addColumn(ColumnConfig.<Record>create("id", "id")
						.setWidth("50px")
						.setCellRenderer(
								cell -> {
									int n = cell.getTableRow().getRecord().id;
									return text((n > 0) ? "" + n : "");
								})
						.setEditableCellRenderer(
							cell -> {
								IntegerBox box = IntegerBox.create().withValue(cell.getRecord().id);
								cell.setDirtyRecordHandler(dirty -> dirty.id = box.getValue());
								return box.element();
							}))
				.addColumn(ColumnConfig.<Record>create("Label", "Label")
						.setWidth("250px")
						.setCellRenderer(
								cell -> {
									int n = cell.getTableRow().getRecord().id;
									return text((n > 0) ? "" + n : "");
								})
						.setEditableCellRenderer(
							cell -> {
								TextBox box = TextBox.create().withValue(cell.getRecord().name);
								cell.setDirtyRecordHandler(dirty -> dirty.name = box.getValue());
								return box.element();
							}))
				.addPlugin(new RowClickPlugin<>(row -> {
					if (row.isEditable()) row.save();
					else  row.edit();
				}))
			;

		DataTable<Record> tbl = new DataTable<>(tableConfig, ds);
		ArrayList<Record>al = new ArrayList<>();
		al.add(new Record(1, "Test 1"));
		al.add(new Record(2, "Test 2"));
		ds.setData(al);
		ds.load();
		return tbl;
	}

@vegegoku vegegoku self-assigned this Nov 28, 2023
@vegegoku vegegoku added the enhancement New feature or request label Nov 28, 2023
@vegegoku vegegoku added this to the 2.0.0-RC5 milestone Nov 28, 2023
@vegegoku vegegoku added the version 2.x.x Version 2.x.x issues label Nov 28, 2023
@vegegoku
Copy link
Member

Please notice that we cant have something like enabled by default, this could lead to different wrong behaviors were we expect the event to propagate and do something, like events that propagate to the body to close opened popups.

We can provide a mechanism to enable and disable this when its is actually need.

@vegegoku
Copy link
Member

TBH, While trying to implement something for this I found that there is nothing I can actually do with a good value behind it and is not complicated, Solutions I thought off ended up more code than what you could do manually to achieve the same result. my suggestion is to do something like this

EventListener clickBlocker = Event::stopPropagation;

then for each editable column fold you can do this

textbix.addClickListener(clickBlocker);

That should do it.

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