pydata / pydata-sphinx-theme

A clean, three-column Sphinx theme with Bootstrap for the PyData community
https://pydata-sphinx-theme.readthedocs.io
BSD 3-Clause "New" or "Revised" License
557 stars 300 forks source link

Fix nbsphinx color outputs, suppress other notebook output Axe errors #1905

Open gabalafou opened 3 days ago

gabalafou commented 3 days ago

Once this PR is merged, running the accessibility checks should execute successfully, with all known failures marked as expected. This should allow us to close #1428 and add the accessibility checks to CI.

gabalafou commented 3 days ago

Submitting this as a draft until I can hunt down what seems to be some kind of race condition (I'm guessing race condition because sometimes the tests pass locally, sometimes not). Sometimes when running the tests locally, the "scollable-region-focusable" Axe check fails, which shouldn't happen because I am asking Playwright to wait for a sign from the script that adds tabindex=0.

gabalafou commented 3 days ago

Getting same confusing Axe failure in CI

gabalafou commented 3 days ago

I think I found the cause of the race condition:

  1. page loads
  2. addTabStopsToScrollableElements() function runs
  3. ipywidgets load, triggering a debounced rerun of the addTabStopsToScrollableElements() function.
    • Note: at this point, the element containing the wide Pandas table in the ipywidget does NOT have tabindex="0"
  4. Playwright runs Axe
  5. The debounced call to addTabStopsToScrollableElements() finally runs and applies tabindex="0" after Axe has already run

With that order of operations, we get a failure for the scrollable-region-focusable Axe check. But if step 5 comes after 6, the check passes.

I rewrote the Playwright script to wait both for the ipywidget table's container to load and for tabindex="0" to be applied.

github-actions[bot] commented 3 days ago

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  src/pydata_sphinx_theme
  __init__.py
  logo.py
  short_link.py
  toctree.py
  translator.py
Project Total  

This report was generated by python-coverage-comment-action