# openElements() not opening elements

**URL:** <https://pdfjs.community/t/openelements-not-opening-elements/138>\
**Category:** Technical Support\
**Created:** [July 15, 2020, 1:50pm UTC](https://pdfjs.community/t/openelements-not-opening-elements/138 "2020-07-15T13:50:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhishek11.maurya199](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@abhishek11.maurya199](https://pdfjs.community/u/abhishek11.maurya199)\
**Post date:** [July 15, 2020, 1:50pm UTC](https://pdfjs.community/t/openelements-not-opening-elements/138/1 "2020-07-15T13:50:21Z")

</div>

Hi,

Below code prints (true,true), but i don’t see toolsOverlay, toolStylePopup both element  
to be open when page loads. It remain close there.Is there any mistake or i left something?

instance.openElements([‘toolsOverlay’]);

instance.docViewer.on(‘documentLoaded’, () =\> {

```
instance.openElements(['toolStylePopup']);

console.log(instance.isElementOpen('toolStylePopup'),instance.isElementOpen('toolsOverlay'));

```

})

My requirement is when i click on shapeToolGroupButton ( Shape button ), automatically,  
toolsOverlay and toolStylePopup should be open for current selected shape, so that i do not have to click again to get the option of color,thickness etc. Is it possible to do that?

If not then any alternative to achieve this.

Regards  
Abhishek Maurya

---

<div class="post-metadata">

**Author:** ![zzhang](https://avatars.discourse-cdn.com/v4/letter/z/b9e5f3/32.png) [@zzhang](https://pdfjs.community/u/zzhang)\
**Post date:** [July 16, 2020, 6:13pm UTC](https://pdfjs.community/t/openelements-not-opening-elements/138/2 "2020-07-16T18:13:43Z")

</div>

Hi,

The reason why they don’t display in the viewer is that the `toolStylePopup` doesn’t know where it should locate itself.

You can listen to the toolModeUpdated event, check the tool names, and then open the component. The code below opens the style popup component when the current tool mode is rectangle tool.

```javascript
instance.docViewer.on('toolModeUpdated', (currTool) => {
  if (currTool.name === 'AnnotationCreateRectangle') {
    setTimeout(() => {
      instance.openElements(['toolStylePopup']);
    }, 0);
  }
})

```

To gain max flexibility, I would suggest you to modify the UI source code, build it, and then integrate the custom UI into your app. If you are going this way then this guide can be helpful [https://pdfjs.express/documentation/ui-customization/advanced-customization](https://pdfjs.express/documentation/ui-customization/advanced-customization).

---

<div class="post-metadata">

**Author:** ![zzhang](https://avatars.discourse-cdn.com/v4/letter/z/b9e5f3/32.png) [@zzhang](https://pdfjs.community/u/zzhang)\
**Post date:** [July 22, 2020, 3:19pm UTC](https://pdfjs.community/t/openelements-not-opening-elements/138/3 "2020-07-22T15:19:33Z")

</div>

Closed on July 22, 2020, 3:19pm UTC


