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

Add new beforeBeginEditing hook #10699

Merged
merged 10 commits into from Jan 11, 2024
Merged

Add new beforeBeginEditing hook #10699

merged 10 commits into from Jan 11, 2024

Conversation

budnix
Copy link
Member

@budnix budnix commented Jan 5, 2024

Context

The PR adds a new beforeBeginEditing hook that allows controlling when the cell editor can (or not) be opened based on the custom condition. When the hook is not used, or if it returns a value other than a boolean, the default behavior is enabled. By default - which is changed within this PR, a cell editor can not be opened by double mouse click for non-contiguous selection (while pressing Ctrl/Cmd) and for multiple selected cells (while pressing Shift).

Before

Kapture 2024-01-08 at 11 44 55

After

Kapture 2024-01-08 at 11 44 09

Hook example usage

Prevent the editor from being opened for the mouse double click. Enter or F2 or API calls would still work.

hot.addHook('beforeBeginEditing', (row, column, initialValue, event, fullEditMode) => {
  return !(event instanceof MouseEvent);
});

Prevent the editor from being opened for specific coordinates (row 0, column 0)

hot.addHook('beforeBeginEditing', (row, column, initialValue, event, fullEditMode) => {
  return row === 0 && column === 0 ? false : true;
});

How has this been tested?

I tested the changes locally and I covered the feature with new tests.

Types of changes

  • New feature or improvement (non-breaking change which adds functionality)

Related issue(s):

  1. fixes https://github.com/handsontable/dev-handsontable/issues/420
  2. fixes https://github.com/handsontable/dev-handsontable/issues/421
  3. fixes https://github.com/handsontable/dev-handsontable/issues/480

Affected project(s):

  • handsontable

Checklist:

@budnix budnix self-assigned this Jan 5, 2024
@budnix budnix marked this pull request as ready for review January 8, 2024 10:45
@budnix budnix requested a review from jansiegel January 8, 2024 10:47
Copy link

github-actions bot commented Jan 9, 2024

Launch the local version of documentation by running:

npm run docs:review 1e110794b0d82f5465a6485708c2eff6335dc44d

@budnix budnix merged commit 2c60f30 into develop Jan 11, 2024
23 checks passed
@budnix budnix deleted the feature/dev-issue-420 branch January 11, 2024 12:49
@magierg
Copy link
Contributor

magierg commented Jan 17, 2024

verified with 0.0.0-next-45ef111-20240116 : https://jsfiddle.net/x73hutLm/4/

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

Successfully merging this pull request may close these issues.

None yet

4 participants