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

Dropdown option is immediately selected due to order of processing touch events #3567

Closed
Adam13531 opened this issue Jan 8, 2020 · 1 comment
Assignees
Labels
issue: bug Describes why the code or behaviour is wrong

Comments

@Adam13531
Copy link

Describe the bug

This bug seems to be a resurfacing of #1804; on mobile, when a dropdown would appear directly over where the user tapped to spawn the dropdown, a selection will be made immediately.

To Reproduce

(note: I did the following steps using this official sample, although I have a local repro too that I can provide if that's insufficient)

  1. Do all of this either from a real mobile device or from Chrome's device emulation (DevTools → Toggle device toolbar)
  2. Create 12 variables with any names (just so that they'll populate the dropdown menu)
  3. Add a "set variable to" block to the canvas
  4. Try opening the dropdown for that block

At this point, the dropdown will open and immediately choose the value underneath your finger/mouse.

Expected behavior

The dropdown stays open so that you can choose an option.

Screenshots

I have a video of myself reproing this: https://clips.twitch.tv/CheerfulCleverKleeOSfrog

Desktop (please complete the following information):

  • OS: Windows
  • Browser: Chrome
  • Version: 79.0.3945.88

Smartphone (please complete the following information):

  • Device: Google Pixel XL
  • OS: Android 10
  • Browser: Chrome
  • Version: 79.0.3945.93

Additional context

We investigated, and the problem is that the dropdown menu is already drawn by the time the event is handled. We wrote a hack to work around this behavior by modifying Blockly directly to stop propagating the event:

--- a/core/components/menu/menuitem.js
+++ b/core/components/menu/menuitem.js
@@ -258,6 +258,29 @@ Blockly.MenuItem.prototype.setEnabled = function(enabled) {
  * @package
  */
 Blockly.MenuItem.prototype.handleClick = function(_e) {
+  var target = _e.currentTarget;
+  var parentMenu = this.getParent();
+
+  if (target &&
+    target.classList.contains("focused") &&
+    this.isEnabled() &&
+    parentMenu.getHighlighted() === null) {
+    return;
+  }
+
   if (this.isEnabled()) {
     this.setHighlighted(true);
     this.performActionInternal();
@Adam13531 Adam13531 added issue: triage Issues awaiting triage by a Blockly team member issue: bug Describes why the code or behaviour is wrong labels Jan 8, 2020
@samelhusseini samelhusseini removed the issue: triage Issues awaiting triage by a Blockly team member label Jan 8, 2020
@samelhusseini samelhusseini added this to the 2019_q4_release milestone Jan 8, 2020
@samelhusseini samelhusseini self-assigned this Jan 8, 2020
@samelhusseini
Copy link
Contributor

Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug Describes why the code or behaviour is wrong
Projects
None yet
Development

No branches or pull requests

2 participants