I have been thinking for a while about the popup system after trying to fix a bug I reported, and I think the popup system could benefit from a little overhaul. I hope I'm not overreaching here - I would just really appreciate some feedback on these ideas!
- Dropdowns (ex. search results, edit toolbar popups) - this is probably the most common
- Menus (a special case of dropdown - ex. the export menu)
- Accordion UI pattern (ex. $:/Manager, plugin info, tiddler info when you click "more > info" in the view toolbar)
- Dialogs (ex. the confirmation prompt when you try to delete tiddlers matching a filter in $:/AdvancedSearch)
So, bearing those four use cases in mind...
What are the requirements of the popup system?
We need popups to open when we activate the corresponding UI element
This mostly corresponds to <$edit-text> and <$button> - but I don't see why we should limit ourselves to these. I like keeping the current shorthand - it makes the common case easy to do, plus it's backwards compatible.
We need popups to close under certain conditions
In my opinion, a popup should close under two conditions:
- If I click on a UI element that completes the workflow that the popup was summoned to complete (applies to dropdowns, menus, and dialogs). For example:
- Clicking on a tag in the tag dropdown
- Clicking on a button in a "confirm" dialog popup
- Clicking on a tiddler in the "create wikitext link" dropdown
- If I click on or otherwise grant focus to an element outside of the popup
- Dialogs are kind of the exception here - clicking outside of a dialog should probably not close it, but I don't think it's the end of the world if it does
- Another exception is the "popup handle" - an input element that's bound to the popup. A prime example of this is the search query edit field - clicking in it shouldn't close the search results
Clicking within a popup shouldn't close it, I think - which is contrary to the current default behavior. I think most people would expect a popup to stick around until they interact with it meaningfully, dimiss it with the button they summoned it with, or click outside of it.
What would a new popup system look like?
I rather like the idea of a new action widget - <$action-popup> - to be the common interface between wikitext and the popup mechanism. It can be the plumbing upon which the higher-level interfaces offered by <$edit-text> and <$button> are built.
A widget can be bound to a popup (similar to how focusPopup works now) - clicking on a widget will not close its own popup (but will close others).
The current popup system currently maintains state in JS; I would really like for the state to be maintained entirely in the tiddler store for consistency purposes.
The current system supports nesting of popups - as far as I can tell, this is only really used for popups that behave like menus, so maybe the right thing to do is to break out a distinct "menu" widget. Doing so might simplify state management quite a bit! It might also make sense to break out a distinct "dialog" widget.
I'm tempted to tie certain bits of extra state to a popup - eg. the search text for "create wikitext link", so that it gets cleared as well when a popup is closed, but maybe that's trying to do too much.
Thinking Ahead
(I have no idea why it just decided to go double-space) There are some other things that users might want popups to do someday; for example, Tobias' appear plugin augments the popup system with some additional behavior, and users might want features like tearoff menus in the future. We can't predict everything everyone might want, but it might be a good time to incorporate augmentations like Tobias' and identify other possible uses for the popup system.Thanks for reading! Please let me know if you have any suggestions, or if you find flaws in my ideas! I'd be happy to undertake this work, as long as it's a solution everyone's happy with.
-Rob