Merge conflict Gerrit cannot merge this change. It needs a rebase onto main.

Review main Ready for review Orphaned

84782[TASK] Make live search pagination accessible by keyboard

Ayke Halder CR 0 V 0 Hard +189 −148 updated 09/24/24, 21:06

Commit message

In live search the pagination can be reached and triggered by keyboard.

Before the pagination was not reachable by keyboard. And the page-items
could only be triggered by 'click'.

This implements real HTML-tags `<button>` inside the web component
element to have the default browser interaction pattern in place.
Otherwise the keyboard interaction like key-press `Enter` or `Space`
needs to be implemented in JS as no automatic interaction model would
be added by the browser.
Before the web component element itself was clickable, but not
accessible by keyboard.

ARIA-labeling is not part of this patch.

Technical changes:

* Closed shadow-root [1] for `<…-pagination>` and `<…-page>`
* Implements `part`-attribute [2] on elements inside `<…-page>` to
  style them from outside via `::part(…)` [3] CSS-selector.
* Implements `exportparts`-attribute [4] on `<…-page>` to even style
  them from outside `<…-pagination>`. The use of `exportparts` can be
  removed again, when the external CSS-styles are incorporated into
  `<…-pagination>` itself.
* `<…-page>` can be reused in other WebComponents as all CSS-styling
  can be done from outside. There is no need to put any CSS-styles into
  `<…-page>`.

[1] https://lit.dev/docs/components/shadow-dom/#setting-shadowrootoptions
[2] https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/part
[3] https://developer.mozilla.org/en-US/docs/Web/CSS/::part
[4] https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/exportparts

**New html-structure:**

```
<typo3-backend-live-search-result-pagination class="open">
  #shadow-root (closed)
  <nav>
    <ul part="pagination">
      <li part="page-item">
        <typo3-backend-live-search-result-page exportparts="button:page-link, button:page-link__first, active:page-link__active">
         #shadow-root (closed)
          <button type="button" part="button" disabled>
            <typo3-backend-icon identifier="actions-view-paging-previous" size="small"></typo3-backend-icon>
          </button>
        </typo3-backend-live-search-result-page>
      </li>
      <li part="page-item">
        <typo3-backend-live-search-result-page exportparts="button:page-link, active:page-link__active">
         #shadow-root (closed)
          <button type="button" aria-current="true" part="button active">
            1
          </button>
        </typo3-backend-live-search-result-page>
      </li>
      <li part="page-item">
        <typo3-backend-live-search-result-page exportparts="button:page-link, active:page-link__active">
         #shadow-root (closed)
          <button type="button" part="button">
            2
          </button>
        </typo3-backend-live-search-result-page>
      </li>
      […]
      <li part="page-item">
        <typo3-backend-live-search-result-page exportparts="button:page-link, button:page-link__last, active:page-link__active">
         #shadow-root (closed)
          <button type="button" part="button">
            <typo3-backend-icon identifier="actions-view-paging-next" size="small"></typo3-backend-icon>
          </button>
        </typo3-backend-live-search-result-page>
      </li>
    </ul>
  </nav>
</typo3-backend-live-search-result-pagination>
```

**Future html-structure with all CSS-styles in `<…-pagination>`:**

```
<typo3-backend-live-search-result-pagination class="open">
  #shadow-root (closed)
  <nav>
    <ul class="pagination">
      <li class="page-item">
        <typo3-backend-live-search-result-page class="first">
         #shadow-root (closed)
          <button type="button" part="button" disabled>
            <typo3-backend-icon identifier="actions-view-paging-previous" size="small"></typo3-backend-icon>
          </button>
        </typo3-backend-live-search-result-page>
      </li>
      <li class="page-item">
        <typo3-backend-live-search-result-page>
         #shadow-root (closed)
          <button type="button" aria-current="true" part="button active">
            1
          </button>
        </typo3-backend-live-search-result-page>
      </li>
      <li class="page-item">
        <typo3-backend-live-search-result-page>
         #shadow-root (closed)
          <button type="button" part="button">
            2
          </button>
        </typo3-backend-live-search-result-page>
      </li>
      […]
      <li class="page-item">
        <typo3-backend-live-search-result-page class="last">
         #shadow-root (closed)
          <button type="button" part="button">
            <typo3-backend-icon identifier="actions-view-paging-next" size="small"></typo3-backend-icon>
          </button>
        </typo3-backend-live-search-result-page>
      </li>
    </ul>
  </nav>
</typo3-backend-live-search-result-pagination>
```

Old html-structure:

```
<typo3-backend-live-search-result-pagination>
 #shadow-root (open)
  <nav>
    <ul class="pagination">
      <li class="page-item">
        <typo3-backend-live-search-result-page class="page-link disabled" page="" perpage="20">
         #shadow-root (open)
          <typo3-backend-icon identifier="actions-view-paging-previous" size="small"></typo3-backend-icon>
        </typo3-backend-live-search-result-page>
      </li>
      <li class="page-item">
        <typo3-backend-live-search-result-page page="1" perpage="20" class="page-link active">
         #shadow-root (open)
          1
        </typo3-backend-live-search-result-page>
      </li>
      <li class="page-item">
        <typo3-backend-live-search-result-page page="2" perpage="20" class="page-link ">
         #shadow-root (open)
          2
        </typo3-backend-live-search-result-page>
      </li>
      […]
      <li class="page-item">
        <typo3-backend-live-search-result-page class="page-link " page="2" perpage="20">
         #shadow-root (open)
          <typo3-backend-icon identifier="actions-view-paging-next" size="small"></typo3-backend-icon>
        </typo3-backend-live-search-result-page>
      </li>
    </ul>
  </nav>
</typo3-backend-live-search-result-pagination>
```

Test this change

Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch

Check out patch set 19
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/82/84782/19 && git checkout FETCH_HEAD
Cherry-pick onto main
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/82/84782/19 && git cherry-pick FETCH_HEAD

Review

  • Code review CR 0 Needs a vote
  • Verified V 0 Needs a vote
    • core-ci +1 CI

Issues 1

Files 7

Review log 2443

Show 1018 earlier messages
  1. Ayke Halder uploaded patch set 1 06/18/24, 17:45

  2. core-ci voted on patch set 1 V +1 06/18/24, 17:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/59820

  3. Ayke Halder uploaded patch set 2 V +1 06/18/24, 17:53

  4. core-ci voted on patch set 2 V +1 06/18/24, 17:58 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/59821

  5. Georg Ringer updated the commit message in patch set 3 V +1 06/18/24, 19:27

  6. core-ci voted on patch set 3 V +1 06/18/24, 19:33 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/59823

  7. Ayke Halder uploaded patch set 4 V +1 06/19/24, 05:14

  8. core-ci voted on patch set 4 V -1 06/19/24, 05:19 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/59841

  9. Ayke Halder uploaded patch set 5 V -1 06/19/24, 05:29

  10. core-ci voted on patch set 5 V +1 06/19/24, 05:35 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/59842

  11. Ayke Halder uploaded patch set 6 V +1 06/20/24, 18:15

  12. core-ci voted on patch set 6 V +1 06/20/24, 18:20 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/59941

  13. Ayke Halder voted on patch set 6 CR +1 V +1 06/21/24, 09:39

  14. Ayke Halder voted on patch set 6 CR 0 V 0 08/22/24, 20:08

  15. Ayke Halder uploaded patch set 7 V +1 09/19/24, 14:38

  16. core-ci voted on patch set 7 V +1 09/19/24, 14:56 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66223

  17. Ayke Halder uploaded patch set 8 V +1 09/19/24, 15:59

  18. core-ci voted on patch set 8 V +1 09/19/24, 16:06 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66227

  1. Ayke Halder updated the commit message in patch set 9 V +1 09/19/24, 16:08

  2. core-ci voted on patch set 9 V +1 09/19/24, 16:14 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66228

  3. Ayke Halder uploaded patch set 10 V +1 09/19/24, 16:24

  4. Ayke Halder updated the commit message in patch set 11 09/19/24, 16:27

  5. core-ci voted on patch set 10 V +1 09/19/24, 16:32 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66229

  6. core-ci voted on patch set 11 V +1 09/19/24, 16:36 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66231

  7. Ayke Halder updated the commit message in patch set 12 V +1 09/19/24, 16:37

  8. Ayke Halder updated the commit message in patch set 13 09/19/24, 16:41

  9. core-ci voted on patch set 12 V +1 09/19/24, 16:46 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66232

  10. core-ci voted on patch set 13 V +1 09/19/24, 16:46 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66233

  11. Ayke Halder uploaded patch set 14 V +1 09/19/24, 17:13

  12. core-ci voted on patch set 14 V +1 09/19/24, 17:18 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66237

  13. Ayke Halder uploaded patch set 15 V +1 09/22/24, 14:37

  14. core-ci voted on patch set 15 V +1 09/22/24, 14:42 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66396

  15. Benjamin Franzke commented on patch set 15 09/23/24, 05:33

    result-pagination.ts:82

    I don't think this needs an extra class, the state and rendering can be contained in ResultPagination, especially since the instance is recreated with every rendering.

    result-pagination.ts:132

    We should implement rtl support into the icon API for semantic icons. let's not use "previous" for forward on rtl, this is not good…

    result-pagination.ts:146

    No createRef()/ref() needed, we can just use `e.currentTarget`, as the event handler is attached to the button this property will always deliver the respective button.
  16. Ayke Halder commented on patch set 15 09/23/24, 06:09

    result-pagination.ts:82 Reply

    ResultPagination is about rendering ResaultPagination. There might be more functionality implemented in the pagination itself: E.g. like properly deciding how many buttons to render depending on the available space. So I do not like to put all 5+ functions needed for the button-state into the ResultPagination. And I also do not like to copy-paste the button-state logic into each button-rendering inside ResultPagination - as the button-rendering-code is used 5 times. ---- The ResultPagination is not recreated every rendering her in search-pagination-context. It's just `this.pagination` which gets updated - and the ResultPagination updates and renders accordingly. https://github.com/TYPO3/typo3/blob/df5fd788639249c19b3de3d26154c0b039c23b70/Build/Sources/TypeScript/backend/toolbar/live-search.ts#L245-L248 ```js private updatePagination(pagination: Pagination): void { const paginationElement: ResultPagination = document.querySelector('typo3-backend-live-search-result-pagination'); paginationElement.pagination = pagination; } ```

    result-pagination.ts:132 Reply

    Acknowledged

    result-pagination.ts:146 Reply

    Acknowledged
  17. Ayke Halder rebased onto patch set 16 V +1 09/23/24, 06:29

  18. core-ci voted on patch set 16 V +1 09/23/24, 06:34 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66410

  19. Ayke Halder uploaded patch set 17 V +1 09/24/24, 14:51

  20. core-ci voted on patch set 17 V +1 09/24/24, 14:57 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66500

  21. Ayke Halder uploaded patch set 18 V +1 09/24/24, 19:49

  22. core-ci voted on patch set 18 V +1 09/24/24, 19:55 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66520

  23. Ayke Halder uploaded patch set 19 V +1 09/24/24, 20:35

  24. core-ci voted on patch set 19 V +1 09/24/24, 20:40 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/66525

  25. Ayke Halder commented on patch set 19 09/24/24, 21:06

    This change solves the problem of reusability of a button-component: By using `part`/`exportparts` HTML-attributes the styling can be completely implemented by an outer component - even when the shadow-root is closed. IMO this is a big point to really implement general purpose LitElements ('atom') - which then can be re-used inside multiple other LitElements ('organism'). Any styling can then be completely implemented inside those 'organisms'. The outsourcing of some functionality into its own small LitElement 'atom', can now done without hindering the approach of an 'organism'-based CSS-styles encapsulation.

    result-pagination.ts:82 Reply Unresolved

    On these button-instances: The buttons were really recreated on every rendering while using the custom JS-class (non-LitElement) from Patchset 17 https://review.typo3.org/c/Packages/TYPO3.CMS/+/84782/17 ---- Now this change is further refined – based again on Patchset 14 with a button-component implemented as LitElement: https://review.typo3.org/c/Packages/TYPO3.CMS/+/84782/14 The current Patchset is 19: https://review.typo3.org/c/Packages/TYPO3.CMS/+/84782/19