Starting from Sitecore 8.1 Update-2, SPEAK team has improved performance while loading Experience Editor. In some cases, it might change the behaviour of current solutions. Make sure that it does not influence on your features.
When I switched to Sitecore 8.1 Update-2 rev. 160302 I encountered problems with a couple of my SPEAK commands located in the Experience Editor Ribbon.
Previously commands were executed every time when I refreshed a page, but after the update only when I switched to the tab where the commands were located.
I figured out that this is an expected behaviour and I’ve got a simple fix for that as well.
If you ever created anything in SPEAK you probably know how SPEAK commands look like.
There are following functions in each of them:
canExecute- executed to determine whether current command can be executed in a current context
execute- invokes page code of a command
For some reason, after the update, my commands were executed only when I switched to a specific tab, where the checkbox is located.
I dug into SPEAK pipelines and found
CheckCommandCanExecute processor in
This processor filters and selects those commands which are valid in the current context and invoke
canExecute function for each.
When I compared two Sitecore versions I found some differences in implementations.
I figured out that there is an additional condition that needs to be meet:
currently active strip/tab need to match strip/tab to which a command belongs.
So that was an answer to my problems. But how to fix this?
Like I said it was done to improve a performance during Ribbon loading in Experience Editor. This is a great move but in my particular case, I could not afford to wait for somebody to switch to a specific tab.
I had to run
canExecute immediately after a page was loaded.
I poked around and found something that could help me achieve my goal.
This is a new property called PostponedCall.
By default this property is empty and in this case it works the same as value True.
canExecute function of your commands will be invoked only when you switch to a specific tab.
The trick here is to set the value of this property to False.
canExecute function of your command will be called on every page load.
If you have any question feel free to ask.