-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes soundasleep/jquery-dropdown#127 (comment) by merging https://github.com/eoghanmurray 's solution (soundasleep/jquery-dropdown@4db65fc).
- Loading branch information
Showing
1 changed file
with
14 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50d336b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a look at the changes, I believe that this version has the drawback that if you have a dropdown-menu within a dropdown-panel, and you select a menu item from the nested menu, then both the nested menu and it's parent panel will be closed, which I don't think is what you want — haven't tested though.
50d336b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with e.g.
targetGroup.is
in this context is that it doesn't differentiate between the current dropdown and parent dropdowns;targetGroup.is('.jq-dropdown-menu')
will return true if any parents are a menu.50d336b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it happens, it is what I want. I have a "Settings" icon that opens a dropdown-panel which shows the various kinds of settings available (a "settings page" or "settings overview"). Some settings are then changed by selecting a new value from a dropdown menu.
Now, in my case, I assume the common use case to be the change of a single setting, so it is convenient for the user that all drop downs close after the selection has been made. You could say that for me a dropdown panel is just like a menu in a nested menu structure, except that the items in that particular menu cannot easily be represented as a list and therefore need the freedom that a panel offers.
Of course, it would be a valid alternative to consider the opening of the "settings (dropdown) panel" the start of a customization process that involves changing several values and requires an explicit close (e.g. by clicking outside the panel -- though I'd offer a close icon/link in addition).
50d336b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine for your usecase and this repository.
Would you agree though that for the general jquery-dropdown project, the other behaviour makes more sense? I can imagine a configuration popup which has a nested dropdown for each setting and a final 'save' button would be a much more common case.
(apologies for using overly personal 'my' and 'you' in the following)
With my behaviour, it's possible to listen for the 'hide' event on the nested dropdown and auto close the parent but with your behaviour, I imagine (although I haven't tried) that it's much more difficult to prevent the auto closing of the parent.
50d336b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not having actual use case data (except from the two of us) makes this a bit philosophical. And, of course, as nobody has officially "adopted" the project, we're all free to follow our own agenda. If I was a bit more of a jquery expert, I would have started a fork, but I'm still trying to fully understand the architecture and therefore I don't feel qualified for this.
This being said, I don't agree with you that a dropdown panel should require an explicit close as default behavior. To me, the dropdown panel and the dropdown menu are just two possibilities to "style" whatever options you want to offer to the user. Nested dropdowns represent a decision tree, no matter what they are composed of. Once the decision is made, that's it.
If I was to develop this library further, I'd introduce the "dropdown dialog" as a flavor of the dropdown panel to cover your use case. A dialog is known to stay open until it is explicitly closed. If I was to do things properly, I'd also make an attempt to implement this "dropdown dialog" as a "merge" of "dropdown panel" and the "standard" jquery-ui dialog, i.e. make its usage as similar to the existing dialog as reasonably possible.
50d336b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hear you — I'm thinking of the dropdown-menu as being like a replacement for a
<select>
, whereas the dropdown-panel is something more; something that can contain many elements and configuration details and which you explicitly dismiss. I've got a<form>
and a submit/save button in my panel.My
<form>
within a panel is a single counter example showing that there are many more usecases than just a decision tree.