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.)

Support from Acquia helps fund testing for Drupal Acquia logo

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
FileSize
4.6 KB

First step.

Wim Leers’s picture

FileSize
26.03 KB
24 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

FileSize
27.21 KB
4.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

FileSize
27.22 KB
807 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.