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 beforeColumnWrap and beforeRowWrap hooks #10550

Merged
merged 9 commits into from Oct 26, 2023

Conversation

budnix
Copy link
Member

@budnix budnix commented Oct 25, 2023

Context

The PR fixes an issue related to unfocusing the table using Tab key when the NestedHeaders plugin was enabled. To fix the error, it was necessary to introduce new hooks that help determine when the moment of row wrapping occurs.

beforeRowWrap hook

const hot = new Handsontable({
  beforeRowWrap: (isWrapEnabled: boolean, newCoords: CellCoords, isFlipped: boolean) => {
  
  }
});

beforeColumnWrap hook

const hot = new Handsontable({
  beforeColumnWrap: (isWrapEnabled: boolean, newCoords: CellCoords, isFlipped: boolean) => {
  
  }
});

Hooks' arguments

  • isWrapEnabled: The argument tells whether the row and/or column wrapping is going to happen. There may be situations where the option does not work even though it is enabled. This is due to the priority of other options that may block the feature. For example, when the minSpareRows is defined, the autoWrapCol option is not checked. Thus, column wrapping is off;
  • The newCoords may help determine what cell will be focused on after the wrapping operation;
  • The isFlipped is set to true when the user reaches the last row/column, and the focus is moved to the first row/column or vice versa, false otherwise.

Miscellaneous changes

The two new methods were added to the CellCoords class. This includes:

  • isRtl() that allows checking if the coordinates running in RTL layout direction mode;
  • assign() that allows assigning coordinates from another CellCoords instance or from a literal object that is compatible with CellCoords schema (has row and/or col properties).

How has this been tested?

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/1499

Affected project(s):

  • handsontable

Checklist:

@budnix budnix self-assigned this Oct 25, 2023
@budnix budnix marked this pull request as ready for review October 26, 2023 09:19
@budnix budnix requested a review from jansiegel October 26, 2023 09:20
@budnix budnix merged commit 50e428d into develop Oct 26, 2023
21 checks passed
@budnix budnix deleted the feature/dev-issue-1499v2 branch October 26, 2023 12:48
@AMBudnik
Copy link
Contributor

AMBudnik commented Dec 1, 2023

Hooks were introduced in v14.0.0. Updated demo https://jsfiddle.net/qsedcahb/8/

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

3 participants