How do you tell if dock is open on a page?

How do you tell if dock is open on a page?

It sounds like you’re asking about Perspective, so I’ll chime in.

If you’re asking from a scripting perspective, you can’t. A Page has no idea about what Docked Views or Popups are displayed; when actions or scripts would expand/collapse a Docked View, that all happens without the page even being aware of it.

BUT… depending on your setup, you could track the state using Session properties to a certain degree.

If you configure the Docked View to be visible only onDemand, AND you do not display handles for the Docked View, AND you expand/collapse the Docked View with your own buttons by invoking your own scripts, you could set the state of the Docked View as a Session property in your script:

self.session.custom.dockedViewIsExpanded = True
self.session.custom.dockedViewIsExpanded = False

Even using the Docked View Action with an accompanying script just to set the state value would be unreliable. The avenue I provided would also fall apart and no longer be accurate if you navigate to pages which do not have the dock in question configured because you could open the dock (and set isExpanded to True), but then navigate away and come back at which point your isExpanded value is still True, but the Docked View will actually be collapsed.

Thanks. Yes, I’m talking about Perspective.

What about via page configuration? If the page is configured to open with a “right dock”?

Is there anyway with scripting to look to see if the current page is configured with a dock?

No, you have access to the attributes (pageId, path of primaryView, session) of a Perspective Page (browser tab), but you do not have access to the Page Configuration.

Can dock collapse/expand events be added so that we can set these session parameters on the dock rather than relying on setting them in every script that opens/closes them? I can definitely see this getting stuck!

There is technically another way to identify the current state of the dock, although it may not be the cleanest

A breakpoint container with embedded views will only load the contents of the embedded view for its current breakpoint.

Meaning that if you have a breakpoint container in an always closed footer/header dock, it should always be loading the current embedded view for the current width breakpoint. If you were expecting a resolution of say 1920, and then when the dock was open you could say your resolution would be 1820, then if the breakpoint was met you would load the “smaller” embedded view, and be able to use message handling to see the current state of the dock.

Like I said, not the cleanest solution, but it is 100% doable

This could also work with multiple device sizes, you would just need to nest your breakpoint containers in a way that gives you more clarity at higher and lower resolutions, instead of just the default size.

I mocked this up in a test project and it worked fine, if needed I could clean up my example and provide it here.

Another way that might be cleaner, albeit I am not sure if its possible

If you are able to grab the current html document for the page, you could take a look for the element by class name docked-view-right (or whichever side) and check if its style: right (or whichever side) is 0px or not. The style: right is set between the width of the view and 0 when the view is opened and closed.

Only thing here is that I am not sure if its possible to grab the current page HTML, I tried, but I couldn’t figure out a way.