handleClick(), root state initialization, setting up event listeners, onpopstate(), Drupal Ajax object creation … they would all benefit from being grouped together into a Controller object.

(I realized this thanks to #2713549-4: Refactor onhashchange event handler away: simplicity, consistency, and avoids a whole class of potential problems with JS using hash-based routing.)

Comments

Wim Leers created an issue. See original summary.

wim leers’s picture

Title: Refactor all the controller logic into an actual object » Refactor all the controller logic into an actual object: improve understandability/maintainability
wim leers’s picture

Status: Active » Needs review
StatusFileSize
new4.6 KB

First step.

wim leers’s picture

StatusFileSize
new26.03 KB
new24 KB

Split out into:

  • HistoryBasedNavigation
  • ClickBasedNavigation
  • Controller

There is unfortunately one regression: when using the "back" button, the scroll position is no longer being restored… deity knows why :(

wim leers’s picture

There is unfortunately one regression: when using the "back" button, the scroll position is no longer being restored… deity knows why :(

Turns out this regression was introduced in #2713549: Refactor onhashchange event handler away: simplicity, consistency, and avoids a whole class of potential problems with JS using hash-based routing! So it'll be up to that issue to fix it.

wim leers’s picture

StatusFileSize
new27.21 KB
new4.89 KB

Changes:

  • Document architecture
  • s/HistoryBasedNavigation/HistoryNavigation/
  • s/ClickBasedNavigation/LinkNavigation/
  • Explicitly document that we should get rid of the currentPos global (but not in this issue)
wim leers’s picture

StatusFileSize
new27.22 KB
new807 bytes

Fix eslint errors.

  • Wim Leers committed d2152a7 on 8.x-1.x
    Issue #2713567 by Wim Leers: Refactor all the controller logic into an...
wim leers’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.