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

**URL:** <https://forum.inductiveautomation.com/t/how-do-you-tell-if-dock-is-open-on-a-page/39293>\
**Category:** Ignition\
**Tags:** perspective, ignition80\
**Created:** [October 2, 2020, 1:39am UTC](https://forum.inductiveautomation.com/t/how-do-you-tell-if-dock-is-open-on-a-page/39293 "2020-10-02T01:39:44Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![ShaneH](https://avatars.discourse-cdn.com/v4/letter/s/3e96dc/32.png) [@ShaneH](https://forum.inductiveautomation.com/u/ShaneH)\
**Post date:** [October 2, 2020, 1:39am UTC](https://forum.inductiveautomation.com/t/how-do-you-tell-if-dock-is-open-on-a-page/39293/1 "2020-10-02T01:39:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [October 2, 2020, 5:36am UTC](https://forum.inductiveautomation.com/t/how-do-you-tell-if-dock-is-open-on-a-page/39293/2 "2020-10-02T05:36:41Z")

</div>

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:

```auto
self.session.custom.dockedViewIsExpanded = True
system.perspective.openDock(id=<dockId>)

```

```auto
self.session.custom.dockedViewIsExpanded = False
system.perspective.closeDock(id=<dockId>)

```

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.

---

<div class="post-metadata">

**Author:** ![ShaneH](https://avatars.discourse-cdn.com/v4/letter/s/3e96dc/32.png) [@ShaneH](https://forum.inductiveautomation.com/u/ShaneH)\
**Post date:** [October 2, 2020, 12:50pm UTC](https://forum.inductiveautomation.com/t/how-do-you-tell-if-dock-is-open-on-a-page/39293/3 "2020-10-02T12:50:07Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [October 2, 2020, 3:54pm UTC](https://forum.inductiveautomation.com/t/how-do-you-tell-if-dock-is-open-on-a-page/39293/4 "2020-10-02T15:54:45Z")

</div>

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_.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [November 4, 2020, 2:51am UTC](https://forum.inductiveautomation.com/t/how-do-you-tell-if-dock-is-open-on-a-page/39293/5 "2020-11-04T02:51:25Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![kgamble](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgamble/32/8019_2.png) [@kgamble](https://forum.inductiveautomation.com/u/kgamble)\
**Post date:** [November 4, 2020, 5:34am UTC](https://forum.inductiveautomation.com/t/how-do-you-tell-if-dock-is-open-on-a-page/39293/6 "2020-11-04T05:34:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kgamble](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgamble/32/8019_2.png) [@kgamble](https://forum.inductiveautomation.com/u/kgamble)\
**Post date:** [November 4, 2020, 5:37am UTC](https://forum.inductiveautomation.com/t/how-do-you-tell-if-dock-is-open-on-a-page/39293/7 "2020-11-04T05:37:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Chris\_Murphy](https://avatars.discourse-cdn.com/v4/letter/c/c5a1d2/32.png) [@Chris\_Murphy](https://forum.inductiveautomation.com/u/Chris_Murphy)\
**Post date:** [August 7, 2023, 9:41am UTC](https://forum.inductiveautomation.com/t/how-do-you-tell-if-dock-is-open-on-a-page/39293/8 "2023-08-07T09:41:09Z")

</div>

I know this is a really old question, but in case anyone else is looking to get around this I have a method with some caveats. I think it would still be good if we could get the dock state either as an event or even better as a page property.  
My method only works to determine that a dock is open, not which dock or if there are multiple open. For my use, this is ok as I am only worried about the vertical menu dock on the left of screen.  
The next limitation is the dock must be set to push, not cover.  
I look at the primary view width vs the viewport width. if they match, then my dock is closed. I use this to animate the hamburger menu button in the header. I use an expression binding like below to get a menu state.

```auto
if({page.props.dimensions.viewport.width} = {page.props.dimensions.primaryView.width}, 'closed', 'open')

```

Hope this helps someone, obviously this method could be used to look at top and bottom docks as well by comparing the heights.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [August 13, 2023, 6:08pm UTC](https://forum.inductiveautomation.com/t/how-do-you-tell-if-dock-is-open-on-a-page/39293/9 "2023-08-13T18:08:28Z")

</div>

I highly advise against string values being used to convey a boolean property/state/value. Consider changing your expression to just this:

```auto
{page.props.dimensions.viewport.width} = {page.props.dimensions.primaryView.width}

```

---

<div class="post-metadata">

**Author:** ![Chris\_Murphy](https://avatars.discourse-cdn.com/v4/letter/c/c5a1d2/32.png) [@Chris\_Murphy](https://forum.inductiveautomation.com/u/Chris_Murphy)\
**Post date:** [September 13, 2023, 6:01am UTC](https://forum.inductiveautomation.com/t/how-do-you-tell-if-dock-is-open-on-a-page/39293/10 "2023-09-13T06:01:59Z")

</div>

I agree and in fact, I do, but I thought it would be a more descriptive snippet as written.  
Are there any plans to add some mechanism to definitively determine the dock states?

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [September 13, 2023, 3:02pm UTC](https://forum.inductiveautomation.com/t/how-do-you-tell-if-dock-is-open-on-a-page/39293/11 "2023-09-13T15:02:00Z")

</div>

Not at this time, no.
