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

Make it possible to disable automatic cursor advance after making an inline edit #2028

Merged
merged 1 commit into from
May 29, 2021

Conversation

ECrosland
Copy link

I mentioned as a side note in bug report #2024 that I would like to prevent the behavior whereby, when enter is pressed to submit an inline edit, the "edit cursor" automatically advances to another editable cell and opens an inline editor for that cell.

I couldn't find an option whereby I might disable this behavior, so I attempted to introduce one. I've called the option advanceOnEdit, and it is set to true by default to preserve existing behavior. My code changes check this setting in two places; I'm not sure whether I've caught all necessary places where the check should be made, so please review.

@ECrosland
Copy link
Author

FWIW, I have a workaround that seems to prevent this "auto-advance" behavior in a recent build of w2ui. It basically checks whether the event that leads to a w2ui editField event was triggered on a w2ui-input element. This feels a bit less than clear, but it does seem to successfully distinguish the case where editField is called on a subsequent cell in response to Enter being pressed in the editor for a previous one. Then I can simply cancel the event.

myGrid.on("editField", function (event) {
	// NB: Seems to only work when selectType is "row", which is OK for my needs.
	const isAutoAdvance = $(event.originalEvent.target).hasClass("w2ui-input");
	if(isAutoAdvance) {
		event.preventDefault();
	}
});

@vitmalina
Copy link
Owner

@ECrosland thank you for you contribution. I think it is a good feature. The only thing I am not sure advanceOnEdit is the best name. What about editAtuoAdvance - I like that it starts with edit as it will be grouped with similar properties/methods, such as editField.

Also, I noticed you pushed to master. Are you already using version of master in your dev? Nice, if it is so. Thought master is still buggy at times. But we are working on it.

@vitmalina vitmalina merged commit f55fb61 into vitmalina:master May 29, 2021
@ECrosland
Copy link
Author

@vitmalina Your thinking on the name makes sense to me.

As for my pushing to master--actually, it's just that I didn't really think it through. I'm still using 1.5 in my project, not 2.0, so, I guess it would be helpful to me to have the change on the 1.5 branch also.

@ECrosland
Copy link
Author

Just created #2032 which adds the option on branch w2ui-1.5. This is the branch that the copy of w2ui in my latest project is built from.

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