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

feat: Add Hybrid Selection Model and Drag-Replace #1091

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft

Conversation

6pac
Copy link
Owner

@6pac 6pac commented Dec 20, 2024

New HybridSelectionModel combines cell and row selection models. It functions like CellSelectionModel except when certain conditions switch it into RowSelectionModel.
If the options.rowSelectOverride function exists, then HybridSelectionModel calls it expecting a boolean return to determine whether to behave like RowSelectionModel.
If this option is not set, then selection of a column that is a member of the array options.rowSelectColumnObjectArr will be treated with the behaviour of RowSelectionModel.

Drag and Replace option mirrors Excel as closely as possible. When a range of cells is selected, a grey box appears at the bottom right of the selection area, and dragging that grey box expands the selection area and replaces the newly selected cells will the contents of the existing cells. Excel specifically only allows expansion horizontally or vertically, but here we allow both. The current behaviour may be modified.
Note that the spreadsheet example the FormulaEditor causes problems with this new feature because it creates a new CellRangeSelector each time a cell is edited. This editor needs to add an event to the existing grid's CellRangeSelector, or create a new one.

@ghiscoding
Copy link
Collaborator

ghiscoding commented Dec 20, 2024

That's interesting, it was asked couple times in my repos on how to do that, so this would surely help a lot. Would you be able to provide an animated gif of this in action (I use ShareX app for that)? I also assume this is not ready yet since I see a few console logs in the code. This remind this issue was brought up in my repo and someone came up with this hybrid approach to toggle between the model depending on the use case, see https://stackoverflow.com/a/76810071/1212166

I also renamed the PR to follow Conventional Commit so that it will be auto-detected in the changelog

I also wonder if this new slick.hybridselectionmodel.ts could eventually replace both previous models? That would probably be a breaking change (major version) but even then it's probably a good idea to keep in mind.

@ghiscoding ghiscoding changed the title Add Hybrid Selection Model and Drag-Replace feat: Add Hybrid Selection Model and Drag-Replace Dec 21, 2024
@6pac
Copy link
Owner Author

6pac commented Dec 22, 2024

@ghiscoding this was actually requested by a client. I'm asking them for an example - the HybridSelectionModel is untested at this point. I'll add gifs for both once I get this.

Correct about it not being finished - the console logs are 100% necessary for any debugging of keyboard or mouse input responses. I will remove them once the client, and you, are happy.

@ghiscoding ghiscoding marked this pull request as draft December 30, 2024 22:40
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