How to default the comment sidebar to CLOSED when viewing records?

Thank you in advance. Some of our Apps take a lot of horizontal space, so our preference is to default with the comments sidebar to closed.

 

I tried this (https://gist.github.com/icoxfog417/8700879) as well as my own JS, but the click() method has no effect on the <a> node, such as below. How can I achieve this?

Thank you! Abdul

<a class=“goog-tab sidebar-tab-comments-gaia goog-tab-selected” title=“Comments” aria-selected=“true” role=“tab” id=":1m" style=“user-select: none;”>Comments</a>

Hello Abdul!

The code that you are trying is utilizing the DOM and when you use DOM to customize kintone, it may not work one day after any kintone version update when the DOM structure changes.

With that being said, the code itself was okay, but the DOM structure kinda changed in recent years; the following code does also utilize the DOM, but it works on the current kintone:

(function() {
"use strict";

kintone.events.on('app.record.detail.show', function(event) {
var handle = document.getElementsByClassName('gaia-argoui-app-show-sidebar-dragged');
handle[0].style.display="none";
});
})();

Again, keep in mind that this might not work again someday after any kintone update.

 

Just for your information, here’s the JavaScript Coding Guideline for kintone:

 

kintone developer network - JavaScript Coding Guideline
https://developer.kintone.io/hc/en-us/articles/213149097/

Hello Yuzo, thank you for your response. However, it doesn’t achieve exactly what I’m looking for. Please see this 2m video response:

https://goo.gl/QEqQ7P

Thank you!

Abdul

Hello Abdul

I saw the video and I understand what you are talking about now. It seems like they changed many things in the structure of the comment box that it currently decides whether to hide or display the comment box using the URL parameter (see below); this is why the comment icon needs to be clicked twice to make it reappear when we’re forcing it to hide using DOM.

Display
&tab=comments

Hide
&tab=none

So, in terms of DOM, I tried many things like editing the “aria-selected” variable upon hiding the comment box using JS, etc., but nothing seems to be working… I guess the only thing you can do is to make a process that will reopen the URL but with the parameter; though, it must have a solid process that will prevent it from looping.

Wow, I didn’t notice the url parameter changing, but it I see it now! I also tried various values for “aria-selected” as I noticed it was one of the attributes that changes when clicking. I think display:none is the safer choice. Thank you for pursuing this for me.

I do think this makes for a good feature request, however; to be able to select the default position: open vs closed.

Hi Abdul, thanks for testing out the JavaScript, and posting your feedback.
I understand your issues here - I’ve shared this with our product team as a feature request :slight_smile:

Thank you. The CSS solution will suffice for now, but a JS solution (not resulting in double-click to open) is preferred.