mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 14:03:30 +00:00 
			
		
		
		
	toggler: Always call back to callback function.
In our toggler component (the thing that handles tabs in things like our markdown/search help, settings/org, etc.), we have a callback mechanism when you switch to the tab. We were being tricky and only calling it when the tab changed. It turns out it's better to just always call the callback, since these things are often in modals that open and close, and if you open a modal for the second time, you want to do the callback task for whichever setting you're going to. There was actually kind of a nasty bug with this, where the keyboard handling in the keyboard-help modal worked fine the first time you opened it, but then it didn't work the second time (if you focused some other element in the interim), and it was due to not re-setting the focus to the inner modal because we weren't calling the callback. Of course, there are pitfalls in calling the same callbacks twice, but our callbacks should generally be idempotent for other reasons.
This commit is contained in:
		@@ -47,15 +47,13 @@ exports.toggle = function (opts) {
 | 
			
		||||
        var elem = meta.$ind_tab.eq(idx);
 | 
			
		||||
        elem.addClass("selected");
 | 
			
		||||
 | 
			
		||||
        if (idx !== meta.idx) {
 | 
			
		||||
            meta.idx = idx;
 | 
			
		||||
            if (opts.callback) {
 | 
			
		||||
                opts.callback(
 | 
			
		||||
                    opts.values[idx].label,
 | 
			
		||||
                    opts.values[idx].key,
 | 
			
		||||
                    payload || {}
 | 
			
		||||
                );
 | 
			
		||||
            }
 | 
			
		||||
        meta.idx = idx;
 | 
			
		||||
        if (opts.callback) {
 | 
			
		||||
            opts.callback(
 | 
			
		||||
                opts.values[idx].label,
 | 
			
		||||
                opts.values[idx].key,
 | 
			
		||||
                payload || {}
 | 
			
		||||
            );
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!opts.child_wants_focus) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user