Changing a held place puts the map into relocating mode: the place being replaced is marked, every place that is not a legal destination is dimmed and made unclickable, and the ones that are left are the only thing a booker can click. The dimming is what makes the gesture work rather than merely look right, because an ineligible place refuses the click in CSS and there is no eligibility test at click time.

It is applied one place at a time. Starting a change walks every drawn place and writes two classes on it, and ending one walks them again to take the classes off. That is two class writes per place to begin and one per place to end, so a hall of twenty thousand places pays sixty thousand DOM writes to move one seat between two of them. They are writes rather than reads, so each one can invalidate style for the element it touches.

Nothing about the decision needs to be made per place. The map already carries the mode on its root while a change is in progress. What the per-place pass adds is which places are eligible, and that is one comparison: a place is a legal destination when it is available and its grade is the grade of the place being replaced.

Proposed resolution

Let the root carry the grade being replaced, give each place its grade as a data attribute when it is drawn, and let CSS do the classification. Everything is dimmed and unclickable while the mode is on; a place whose grade matches the root and which is available is exempted. Beginning and ending a change then costs one attribute on one element instead of a pass over the hall, and the drawing loop that already exists is where the grade attribute is set, so there is no extra pass to add it.

This is meant to leave the behavior exactly as it is, including what is dimmed, what stays clickable and what the place being replaced looks like. The functional JavaScript coverage of the change gesture is what says so, and it should be run before and after rather than trusted.

Remaining tasks

  • Carry the grade on each drawn place, and the grade being replaced on the map.
  • Move the dimming and the pointer rule into CSS, and delete the per-place pass at both ends of the gesture.
  • Run the existing change-a-place coverage before and after, so behavior is shown to be unchanged rather than assumed.

Also worth a line while the code is open

The hint shown during a change says to pick another available place in the same tariff, while the rule that decides it compares grades. The two agree in practice, because a tariff prices grades, but they are not the same sentence: a tariff pricing several grades would dim places the wording invites the booker to pick. Either the words or the rule should move.

Where it came from

Found while reviewing what walks the whole hall on a hot path, alongside the shared stepper work in #3615940: Share one stepper widget, and coalesce a booker's clicks into one request. That issue removed the scans it had introduced and left this one alone, because a change of place is a deliberate and infrequent gesture and rewriting it is not that issue business.

Issue fork yoyaku-3616042

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mably created an issue. See original summary.

  • mably committed c66bd20e on 1.x
    task: #3616042 Locking the hall for a place change writes a class on...
mably’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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