Skip to content

Comments

Ignore inner updates on a stimulus-reflex action or turbo submit#174

Merged
julianrubisch merged 3 commits intostimulusreflex:masterfrom
julianrubisch:inner-updates-compat
Jan 6, 2022
Merged

Ignore inner updates on a stimulus-reflex action or turbo submit#174
julianrubisch merged 3 commits intostimulusreflex:masterfrom
julianrubisch:inner-updates-compat

Conversation

@julianrubisch
Copy link
Contributor

@julianrubisch julianrubisch commented Jan 4, 2022

Let me preface this PR with the fact that this is already being used successfully in production and is intended as a backmerge of the work I'm doing at https://github.com/code-and-co/.

The idea is to opt out of an updates_for operation for the current user on a per-element basis, when a reflex or turbo submit is happening (for example, when wrapping a <turbo-frame>).

Conceptually, it consists of 3 parts:

javascript/updatable/inner_updates_compat.js

which recursively marks every enclosing updates-for element with performing-inner-update, starting from a reflex or turbo submit initiating element. This attribute is removed again after completion.

An ignore_inner_update option added to the helper

which adds a ignore-inner-update attribute to the element on demand.

A shouldUpdate mechanism

combining the existing "only" option and returning early when both ignore-inner-updates and performing-inner-update are set on an element.

cc @andrewerlanger @assuntaw

Copy link
Contributor

@leastbad leastbad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I sincerely hope that this is the last hairy edge case, for our sanity.

Anyhow: LGTM, moderated to a really liberal definition of "good" - I wish it wasn't necessary, but I agree with you that it is, and very much appreciate that you have championed getting this done properly.

@julianrubisch julianrubisch force-pushed the inner-updates-compat branch 3 times, most recently from 5ce6474 to 9a53dec Compare January 6, 2022 16:02
@julianrubisch julianrubisch merged commit 504ae49 into stimulusreflex:master Jan 6, 2022
@julianrubisch julianrubisch deleted the inner-updates-compat branch January 6, 2022 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants