RapiDoc icon indicating copy to clipboard operation
RapiDoc copied to clipboard

Collapsible tag groupings for read/focused render mode

Open reyolivo opened this issue 5 years ago • 9 comments

Hello, my team also has some large spec files and we really love the focused mode-render for our use case. Yet, we'd really need to have some collapse/expanded functionality for the tag groupings to prevent massive page scrolling. Unfortunately, the change below only applies to the "view" render mode. I tried it with our own JSON file, and even altered the example's html for the render mode to be "read/focused", but no luck:

#171

I also asked part of this question in that thread above, but it probably deserves it's own issue thread. So, two things:

  1. (tactical question) Any way to use the "x-tag-expanded=false" flag solution for read/focused render modes?

  2. (strategic question) Can we have a Boolean flag to set at the rapi-doc element-level to initially have all tag groupings to be expanded or collapsed? It seems to be overkill to have to iterate through the JSON and alter each tag to have the x-tag-expanded attribute, particularly, for use cases like ours where the swagger.json file is dynamically generated at load time.

Thank you!

reyolivo avatar Jan 29 '21 16:01 reyolivo

for clarification - are you asking for collapse/expand feature on the sidebar ?

mrin9 avatar Jan 29 '21 17:01 mrin9

correct @mrin9 , on the navigation bar on the left for those read/focused modes

reyolivo avatar Jan 29 '21 17:01 reyolivo

(tactical question) Any way to use the "x-tag-expanded=false" flag solution for read/focused render modes?

I have included the suggestion in our feature-request. IMO it may be accepted to extend this functionality to focused mode only. In read expand/collapse is little tricky as the scrolling on the main content also triggers highlighting the items on the sidebar. if there is a collapsed item on sidebar this will require us to first expand and then highlight it, and then back to collapsed state when the user further scroll away. Our UX do not recommend auto-collapse/expand due to a scroll action, it is a side-effect and leaves many user in a confused state when they see things expanding/collapsing due to their scrolling

(strategic question) Can we have a Boolean flag to set at the rapi-doc element-level to initially have all tag groupings to be expanded or collapsed? It seems to be overkill to have to iterate through the JSON and alter each tag to have the x-tag-expanded attribute,

it is a question of flexibility, allowing per-tag setting allows you either collapse all the tags or few of the tags. a global option will leave you either collapse all tags or none. providing both option is something that we try to avoid as it creates confusion about which one takes precedence

particularly, for use cases like ours where the swagger.json file is dynamically generated at load time.

I think it is easier to apply per-tag setting if you are generating it dynamically, well it depends upon what tool you are using to generate i,. for instance swagger-core which generates Java/JAX-RS based open API spec has dedicated annotations to add vendor-extentions

mrin9 avatar Jan 29 '21 19:01 mrin9

Yes I agree, the tactical feature request only really applies to the focused view, which is what I am trying to use as well. That makes sense that it wouldn't work for the read mode.

For the strategic solution, that makes sense to avoid having both options to avoid user confusion. I can look into adding those vendor extension annotations, especially once the focused-mode starts correctly capturing that extension flag.

To follow up, for the tactical feature request, is there a way for me to track the progress on that feature? Would just love to have a ballpark idea of when it'll get prioritized and released. I really think this fix would truly make large specs even more easy to navigate and offer an optimized UX.

Thanks for your help and for this great tool! Let me know if I can be of any help.

-Rey

reyolivo avatar Jan 29 '21 19:01 reyolivo

refer this https:/rapidocweb.com/examples/collapsable-focused.html#overview to check it out

mrin9 avatar Jan 31 '21 06:01 mrin9

Thank you @mrin9! It's looking good, the only thing I saw that seemed off was when you do a 'Collapse All' and then Search for let's say "Closed" then nothing happens. Everything else on that demo seems to work perfectly. Also, I can't seem to get it to work on my end, but my guess is that you haven't released it to https://unpkg.com/rapidoc/dist/rapidoc-min.js ?

reyolivo avatar Feb 01 '21 14:02 reyolivo

Quick Search which is more of a filter, will not expand or collapse any tags, However it does filter out paths. Thats is after filtering if you expand a collapsed tag you will find only filtered path under it. This is an intended design as auto-expansion has a potential to expand many tags at once, which may not sit well with the user as s/he may have have to collapse them all over again.

Advanced search will open up the collapsed tag as it will open only one.

this is an unreleased feature, to check it your end you can pick up the code from dist/rapidoc-min.js folder

mrin9 avatar Feb 01 '21 16:02 mrin9

I see what you mean @mrin9 . It might be nice to change the default "Quick Search" text box to say "Quick Filter", or something along those lines. Yet, in my opinion, having this quick search functionality to be used as a Search and not a Filter might be more user friendly. Else, if you collapse a Tag group, and then filter for something that might apply to that Tag's group, then nothing will happen.

In other words, it seems to be more intuitive to have that Quick Search bar be able to actually expand/collapse tags as necessary....it does this anyway when you first load the spec with some initially collapsed Tags. The way it is now just appears to have an inconsistent updating of the collapse/expand state - at least when I compare the search behavior's impact on auto collapsing/expanding right after initial the spec load VS the related behavior after manual collapse/expand actions.

E.g, in your example, if you do a quick search for the word "Closed" it will collapse the "Open" Tag and expand the "Closed" tag.

If you then clear that, and manually collapse the "Closed" tag group, and search for "Closed" again, then you will see a different behavior. This is essentially the inconsistency that I am referring to that could confuse users.

The two solutions that come to mind for this are to either make the behavior consistent (make the quick search auto update the collapse/expanded state). The second solution is to change the "Clear" button to say something like "Restore to default" (or just make this a separate button) which would then restore the collapsed/expanded state and the Quick Search state back to its original setting. Either solution would work for me.

Lastly, when does ReDoc usually drop it's releases on the UNPKG distribution?

Thanks!

reyolivo avatar Feb 01 '21 19:02 reyolivo

E.g, in your example, if you do a quick search for the word "Closed" it will collapse the "Open" Tag and expand the "Closed" tag.

it does not collapse "Open" tag, but since there are no paths containing the word closed under "Open" tag it list none , that doesn't mean it is collapsed, check the expand/collapse icon on right which indicates if a tag is collapsed or expanded. Now in the same example try quick search for path1, this will hide all the other paths under open and closed tags,

So the behavior is consistent in case of quick search (it wont collapse or expand tags)

when does ReDoc usually drop it's releases on the UNPKG distribution?

we do not have a set schedule for this, once we get a green signal from QA, we try to cut a release, you can checkout the timeline of our past releases, that may provide you a trend or some idea

mrin9 avatar Feb 01 '21 20:02 mrin9