Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tabs (toggleSections) does not work if localStorage is unavailable #3323

Closed
echeung-amzn opened this issue Nov 9, 2023 · 0 comments · Fixed by #3588
Closed

Tabs (toggleSections) does not work if localStorage is unavailable #3323

echeung-amzn opened this issue Nov 9, 2023 · 0 comments · Fixed by #3588
Assignees
Labels
bug format: html An issue/PR related to Dokka's default HTML output format html: frontend An issue/PR that only or primarily requires frontend work (html/css) tech-debt A technical issue that is not observable by the users, but improves maintainers quality of life

Comments

@echeung-amzn
Copy link

Describe the bug

  1. Deploy Dokka-generated docs to some platform that renders docs within a sandboxed iframe.
  2. Navigate to some page that has tabs, such as a class that has Types, Constructors, Functions, and Parameters.
  3. Try to navigate to another tab such as Constructors.
  4. Does not switch to tab due to sandboxing preventing the usage of localStorage.

Example stack trace from browser console:

Uncaught DOMException: Failed to read the 'localStorage' property from 'Window': The document is sandboxed and lacks the 'allow-same-origin' flag.
    at toggleSections (https://[redacted]/dokka/scripts/platform-content-handler.js:251:5)
    at toggleSectionsEventHandler (https://[redacted]/dokka/scripts/platform-content-handler.js:270:5)
    at HTMLDivElement.<anonymous> (https://[redacted]/dokka/scripts/platform-content-handler.js:161:58)
toggleSections @ platform-content-handler.js:251
toggleSectionsEventHandler @ platform-content-handler.js:270
(anonymous) @ platform-content-handler.js:161

Expected behaviour
Other tab is shown even if localStorage is unavailable.

Screenshots
N/A

To Reproduce

<iframe
  src="https://[redacted]/dokka/index.html" 
  sandbox="allow-modals allow-popups allow-scripts allow-top-navigation-by-user-activation allow-downloads">

Dokka configuration
Configuration of dokka used to reproduce the bug

register<DokkaTask>("dokka") {
    outputDirectory.set(file("[redacted]/dokka"))
    dokkaSourceSets.configureEach {
        externalDocumentationLink {
            noJdkLink.set(true)
            noStdlibLink.set(true)
            noAndroidSdkLink.set(true)
            url.set(URL("[redacted]"))
            packageListUrl.set(URL("file:///[redacted]"))
        }
    }
}

Installation

  • Operating system: Linux
  • Build tool: Gradle v7.6.1
  • Dokka version: 1.6.21

Additional context
I understand that the use of localStorage was added in #921 to persist the tab state across page navigations. However, it'd seem appropriate to silently fail and still allow tabs to be shown even if localStorage cannot be used, at the expense of a lack of persistence.

Are you willing to provide a PR?
I could try taking a stab at it.

@IgnatBeresnev IgnatBeresnev added format: html An issue/PR related to Dokka's default HTML output format tech-debt A technical issue that is not observable by the users, but improves maintainers quality of life html: frontend An issue/PR that only or primarily requires frontend work (html/css) labels Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug format: html An issue/PR related to Dokka's default HTML output format html: frontend An issue/PR that only or primarily requires frontend work (html/css) tech-debt A technical issue that is not observable by the users, but improves maintainers quality of life
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants