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

Prevent unnecessary deselect/select when an already selected item is selected #1449

Merged
merged 1 commit into from
Apr 7, 2020

Conversation

msssk
Copy link
Contributor

@msssk msssk commented Jan 17, 2020

Fixes #1011

When a selected row or cell is clicked on (or focused and spacebar pressed) dgrid will deselect it (and fire a deselect event) and re-select it (and fire a select event). This PR prevents the unnecessary deselect/select process.

@@ -285,6 +285,12 @@ define([
// except that clicks/keystrokes without modifier keys will clear
// the previous selection.

// If the target is already selected, and is the sole selection, ignore a user action
// that would simply select the target (causing unnecessary deselect/select).
if (!event[ctrlEquiv] && this.isSelected(target) && this.getSelectedCount() === 1) {
Copy link
Contributor

@maier49 maier49 Apr 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the line below where we're checking for the control key the logic used is
!(event.keyCode ? event.ctrlKey : event[ctrlEquiv])

Should we be replicating the same check here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't think of why that logic would be used anywhere. It only makes sense to me if:

  1. Mac browsers typically don't supply a value for event.keyCode
  2. There is a specific browser for which has('mac') is true, and that browser does supply a value for event.keyCode, and instead of event.metaKey it sets event.ctrlKey when the Command key is pressed

I haven't found any discussion of ctrlKey/metaKey that justifies this logic. Am I missing something?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I don't know of any situation where that makes sense.

@msssk msssk merged commit 55f96bd into dojo:master Apr 7, 2020
@msssk msssk deleted the 1011-extended-selection-event branch April 7, 2020 21:34
@msssk msssk unassigned dylans Apr 7, 2020
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.

Both deselect and select events are fired with extended selection mode
3 participants