We recently had an odd scenario where Sitecore EditFrame buttons would seemingly disappear randomly. Our edit frame made use of a mixture of Field Editor Buttons (‘/sitecore/templates/System/WebEdit/Field Editor Button’) and Edit Frame Small Buttons (‘/sitecore/templates/System/WebEdit/Edit Frame Small Button’).
We never had problems with the field editor buttons just the edit frame small buttons. On these buttons the clicks are bound to Sitecore commands. Behind the scenes these commands evaluate their querystate to check if they should be visible, disabled or active:
1 2 3 4 |
public override CommandState QueryState(CommandContext context) { ... } |
The buttons had a mixture of commands, some custom and some out the box. Examples of the out the box commands were:
1 |
item:movedown, item:moveup |
Note, to find the code that runs for these commands, have a look in /App_Config/commands.config and search for the specific command name.
After debugging into our custom commands vs the out the box commands we found things like item:movedown has the following checks:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
public override CommandState QueryState(CommandContext context) { if (context.Items.Length == 0) { return CommandState.Disabled; } Item item = context.Items[0]; if (!base.HasField(item, FieldIDs.Sortorder)) { return CommandState.Hidden; } if (item.Appearance.ReadOnly) { return CommandState.Disabled; } if (!item.Access.CanWrite()) { return CommandState.Disabled; } if (Command.IsLockedByOther(item)) { return CommandState.Disabled; } if (!Command.CanWriteField(item, FieldIDs.Sortorder)) { return CommandState.Disabled; } return base.QueryState(context); } |
The check that was catching us out was the if (Command.IsLockedByOther(item)) clause.
I’d never have thought to check an item locks as being the cause of EditFrame buttons not showing!!! The more I think about it I can see why the check is there – things like sort order are stored as fields against an item so if they are locked, you shouldn’t be able to edit them. From a UI perspective, it appears edit frame buttons don’t distinguish between CommandState.Disabled and CommandState.Hidden.