RFC: Conditional UI elements Tabs/buttons and more

Hi folks, I have long wanted an easy way to add a condition to tabs and buttons and was recenly looking at editor toolbar buttons, they use the condition field and typicaly test the type field to determin if they should display the button or not.

I raise this RFC because this feature would idealy be implemented in the core eventualy

I have often wrapped the body content of buttons in a display condition and buttons will not show if this condition is appropriate. But for consistency I am modifying the toolbar UI elements to also test the condition field before display. By default if there is not condition fields or its empty there is no change.

However this is not true for the tabs macro, all tabs will show until you remove the validity of the filter that includes it eg; remove “$:tags/sidebar” so I have rewritten it to also first look at the condition field before displaying the tab. This allows individual tabs to have their own conditions.

  • Possibly a key use is when in read only, author or designer modes.
  • I have more to say on that later.

I am progressivly implementing this as a Proof of concept here conditional-elements feel free to have a look and use differences from shadow to see my modifications.

RFC Request for comment - current solution

I am seeking feedback on how I have coded my solution because although I can deliver it by package or plugin initialy it ONLY changes core UI tiddlers and I would hope eventualy to petition for this to be included in the next release.

But there is a little, more for shadows

Inevitably people will want to add a condition field to a range of existing core UI tiddlers and this will both interfear with core upgrades and make the wiki larger, as we then need to store the shadow and the tiddler in the wiki, such as the sidebar and other tabs, I would like to implement an additional method so;

if there is no condition field on a given tab or button it first looks for an external condition specified for the tiddler.

This is where I also seek COMMENT what do you think is the best way to achive this? Options may include;

  • A data tiddler containing the tiddler title and the value is the condition
  • A tiddler for each tiddler having an overide condition (like the visibility ones)
    • $:/config/conditions/ tiddlername containing the condition in its test field
  • Perhaps a condition tag or cascade mechanisium so different solutions can contribute additional conditions to display or hide the item
  • Another idea I have is a virtual field, one of any number fields people can add to a single additional tiddler I refer to as a ghost tiddler.
    • Many other features could be built into this, but other plugins would be able to leverage this as well.
  • Or some other approach?

This is where my other post today comes in RFC Ghost tiddlers

Post Script:

Perhaps we can extend the condition field to tags and the display of tag pills?

  • That is if a tag tiddler has a condition field use that to see if it is to be displayed.
  • You could then hide system tags unless in design mode.

The “tag” and “tag-pill” code is super old, super annoying to read and close to impossible to modify in the current stage. So it would be nice if it would get some love.

Starting with new formatting, that makes it human readable as a first PR. Mixing new function and new formatting has no chance to be merged into the core.

I agree its difficult but I am not Personaly confident rewriting the tag pill macro iAlthought I have things I want to add;

  • alternate Lables
  • condition filter
  • subfilter option to vary the tiddler lists eg tag todo dont list done.
  • drop title on tag to tag it

I have also developed a “filter pill” which is somewhat better.

My reimagin tags package includes features on the tag pill of substantial value that many of them could be provisioned in the core macro even if off by default with supporting settings.

It would be trivial to allow additional settings for tags to be stored in the actual tag tiddler.

I would like to bump this and invite more developers to comment, I hope to get this raised to introduce in the next release. I have published a wiki to look at conditional elements and preview difference from shadow you can see my “minimal edits”.

I expect I will submit each separately but the key issue to socialise is extending the use of the “condition” field, from the editor toobar, to the following;

  • tabs Macro
  • Buttons
    • page Controls
    • view toolbar
    • edit toolbar

The above are already implemented on the site above.

This means extending the possibility of the condition field on many different tiddlers only when required.

With similar methods planned for;

  • Conditional tag pills
  • Menu plugin conditional items?
  • View template elements $:/tags/ViewTemplate
  • Edit template elsements $:/tags/EditTemplate and $:/tags/EditorTools

Once these changes are accepted and implemented I hope to develop the meta tiddler idea and allow any core tiddler to retrieve the condition field from a separate tiddler.

I have also observed that the Info button tabs, in the info dropdown, are always displayed. For example you may often click on the backlinks tab to discover there are no backlinks. As a result it is a waste of time.

By adding a condition to each of these tabs they will only display if there is something to display so another reason to implement this proposal.

In that particular case it’s worth noting that this would require backlinks to be computed continuously while the info panel is displayed. Backlinks computation is expensive, so it is sometimes advantageous that the user has to explicitly click the tab to display them.

Thanks @jeremyruston,

  • I suppose I want to quantify the impact to see if it is prohibitive or not.
  • Would this only occur when the user opens the info tab drop down? As it iterates the tabs it will do this condition check or later when something triggers a refresh?
  • Will it only occur on opening info tabs and any that are left open or on all tiddlers without even a visible info tab?

Hi @TW_Tones if a set of tabs is displayed, then the condition field of each tab would be evaluated in every refresh cycle. So there would only be an impact if the info panel was open.

1 Like