hedyorg / hedy

Hedy is a gradual programming language to teach children programming. Gradual languages use different language levels, where each level adds new concepts and syntactic complexity. At the end of the Hedy level sequence, kids master a subset of syntactically valid Python.
https://www.hedy.org
European Union Public License 1.2
1.31k stars 289 forks source link

[UI idea] Make cheatsheet and command toggle mutually exclusive #4619

Closed TiBiBa closed 1 year ago

TiBiBa commented 1 year ago

Idea incl level This is a bit crowded, one should close when the other is openend:

Scherm­afbeelding 2023-10-11 om 13 29 13

hasan-sh commented 1 year ago

Good catch. This is a general behavior, i.e., it actually happens with other menu types as well. For instance, the profile one: image

TiBiBa commented 1 year ago

This should be easy to solve as all dropdown menu's should inherit the same class dropdown. When clicking a menu we should simply close all that are not the one we click before toggling the one we target.

TiBiBa commented 1 year ago

Weird, the code is already here in app.ts:

// Close the dropdown menu if the user clicks outside of it
  $(document).on("click", function(event){
      if(!$(event.target).closest(".dropdown").length){
          $(".dropdown-menu").slideUp("medium");
          $(".cheatsheet-menu").slideUp("medium");
      }
  });

Will look into this and generalize the functionality as well as debug this issue.

hasan-sh commented 1 year ago

Weird, the code is already here in app.ts:

// Close the dropdown menu if the user clicks outside of it
  $(document).on("click", function(event){
      if(!$(event.target).closest(".dropdown").length){
          $(".dropdown-menu").slideUp("medium");
          $(".cheatsheet-menu").slideUp("medium");
      }
  });

Will look into this and generalize the functionality as well as debug this issue.

This logic doesn't work properly. The reason is that all buttons that trigger sliding a dropdown have the .dropdown class, therefore, it won't work. I think it's a flaw of the initial design of the generalization these dropdowns since the they don't occur in the same position always (i.e. the triggers nor the dropdowns) . A quick fix would be going through all dropdowns and see if the click event target isn't the one that's really close to the dropdown at hand! Will fix it and do a pr in a bit.