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(selection): copy text selection now working, closes #334 #333

Merged
merged 1 commit into from
Feb 7, 2019

Conversation

ghiscoding
Copy link
Collaborator

@ghiscoding ghiscoding commented Feb 5, 2019

  • onSelectedRowsChanged should ONLY trigger when new selected rows are different compare to previously selected rows
  • the issue comes from "slick.checkboxselectcolumn.js" that has a subscribe to "onSelectedRowsChanged" and when copying text selection, this was triggering a row selection (which is incorrect when row was already selected and doesn't change) and this in turn was calling an "invalidateRow" which finally removes focus of the cell

This fixes issue #334 (and possibly #150), in brief user cannot copy text selection when row is the selected row (even when it's the same selected row). Also note that I have enableTextSelectionOnCells enable but that was not helping with my issue. This was also mentioned in a very old issue #9, this PR fixes exactly that but at the source instead of in each plugins (checkbox selector was not covered in #9 fix).

Origin of the issue

handleSelectedRangesChanged was always triggering the event onSelectedRowsChanged, even when the row selected is exactly the same. That was doing a cascading effect of triggering handleSelectedRowsChanged of slick.checkboxselectcolumn.js, which inside had an grid.invalidateRow(row) that was doing the blur effect since the row was getting re-rendered and when that happens it obviously remove text selection focus since the DOM element gets recreated.

Fix

We should trigger an onSelectedRowsChanged event ONLY when the previously selected row(s) is not the same as the newly selected row(s) and that's it, we don't need to re-render and that fixes text selection.

Before the fix (I cannot keep text selection, it always blur away on the selected row)
2019-02-05_18-42-29

With FIX
2019-02-05_18-43-12

- onSelectedRowsChanged should ONLY trigger when new selected rows are different compare to previously selected rows
- the issue comes from "slick.checkboxselectcolumn.js" that has a subscribe to "onSelectedRowsChanged" and when copying text selection, this was triggering a row selection (which is incorrect when row was already selected and doesn't change) and this in turn was calling an "invalidateRow" which finally removes focus of the cell
@ghiscoding
Copy link
Collaborator Author

@6pac
Once this PR is merged, would it be possible to release a new version on NPM? There are a few fixes that I'd like to use in my repos. Thanks

@ghiscoding ghiscoding changed the title fix(selection): copy text selection now working fix(selection): copy text selection now working, closes #334 Feb 6, 2019
@6pac
Copy link
Owner

6pac commented Feb 7, 2019

No probs, we are building up quite a few small changes. I'll leave the merging of this to you, let me know when you're ready for the release. (It is my custom to wait a day after the last pull for the inevitable patch).

@ghiscoding ghiscoding merged commit 692785a into master Feb 7, 2019
@ghiscoding
Copy link
Collaborator Author

Thanks, you are definitely right about the last minute patches. I'll give another try in repos with latest merged code. I'll do that tomorrow.

@ghiscoding ghiscoding deleted the bugfix/copy-text-selection branch February 7, 2019 20:05
@ghiscoding
Copy link
Collaborator Author

@6pac
You were right about the last minute patches, I did have to fix 2 small issues. I'm done with them and the testing, it's good on my side now, I'd be happy to see a new NPM version when you have a chance

@6pac
Copy link
Owner

6pac commented Feb 9, 2019

Released 2.4.3

@ghiscoding
Copy link
Collaborator Author

Awesome, thanks 😃

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

Successfully merging this pull request may close these issues.

2 participants