 
   updateAttributes: (attributes) ->
     @attributes = attributes
-    @eachAttributeButton (element, attributeName) ->
-      if attributes[attributeName]
+    @refreshAttributeButtons()
+
+  refreshAttributeButtons: ->
+    @eachAttributeButton (element, attributeName) =>
+      if @attributes[attributeName] or @dialogIsVisible(attributeName)
         element.classList.add("active")
       else
         element.classList.remove("active")

    else
      @delegate?.toolbarDidToggleAttribute(attributeName)

  didClickDialogButton: (event, element) =>
    dialogElement = findClosestElementFromNode(element, matchingSelector: dialogSelector)
    method = element.getAttribute("data-method")


  # Dialogs

  dialogIsVisible: (attributeName) ->
    if element = @getDialogForAttributeName(attributeName)
      element.classList.contains("active")

  toggleDialog: (attributeName) ->
    if @dialogIsVisible(attributeName)
      @hideDialog()
    else
      @showDialog(attributeName)
