Skip to content
Snippets Groups Projects
Commit ad986216 authored by Diego Sampaio's avatar Diego Sampaio
Browse files

improved closeFlex logic when switching tabbars

parent 8c36dd9b
Branches release-5.3.3
Tags 5.3.3
No related merge requests found
......@@ -2,15 +2,11 @@ Template.flexTabBar.helpers
active: ->
return 'active' if @template is RocketChat.TabBar.getTemplate() and RocketChat.TabBar.isFlexOpen()
buttons: ->
RocketChat.TabBar.getButtons()
return RocketChat.TabBar.getButtons()
title: ->
return t(@i18nTitle) or @title
visible: ->
if @groups.indexOf(RocketChat.TabBar.getVisibleGroup()) is -1
# if it was active, close it
if @template is RocketChat.TabBar.getTemplate() and RocketChat.TabBar.isFlexOpen()
RocketChat.TabBar.closeFlex()
return 'hidden'
Template.flexTabBar.events
......@@ -29,3 +25,18 @@ Template.flexTabBar.events
RocketChat.TabBar.setTemplate @template, ->
$('.flex-tab')?.find("input[type='text']:first")?.focus()
$('.flex-tab .content')?.scrollTop(0)
Template.flexTabBar.onCreated ->
# close flex if the visible group changed and the opened template is not in the new visible group
@autorun =>
visibleGroup = RocketChat.TabBar.getVisibleGroup()
Tracker.nonreactive =>
openedTemplate = RocketChat.TabBar.getTemplate()
exists = false
RocketChat.TabBar.getButtons().forEach (button) ->
if button.groups.indexOf(visibleGroup) isnt -1 and openedTemplate is button.template
exists = true
unless exists
RocketChat.TabBar.closeFlex()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment