Skip to content

Route prefix to support hash location #641

@Aloren

Description

@Aloren

I have a single page containing multiple rapi doc elements:

                <rapi-doc
                        id="rapidoc-service-x"
                        update-route="true"
                        route-prefix="#tab-service-x/"
                        render-style="read"
                        ... other configs ommitted...
                ></rapi-doc>

I use hashlocation to show API documentation (activate specific rapidoc element) for a specific service.

The following url is created when specific operation is selected:

http://localhost:8080/#tab-service-x/post-/smth/-smth1-/smth2

And unfortunately this url does not scroll to the specific operation.
I've looked into how the scrollTo method is used:

this.scrollTo(window.location.hash.substring(1));

and it's implementation:

async scrollTo(elementId, expandPath = true, scrollNavItemToView = true) {
... other code ommitted...
      const contentEl = this.shadowRoot.getElementById(elementId);
      if (contentEl) {
        isValidElementId = true;
        contentEl.scrollIntoView({ behavior: 'auto', block: 'start' });
      } else {
        isValidElementId = false;
      }

So according to the following code, rapidoc is not able to find the element due to tab-service-x/ in the hash.
As I understand, route-prefix is not intended to be used as hash-location prefix now. But is it possible to support such behavior?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions