-
Notifications
You must be signed in to change notification settings - Fork 436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugfix: Form Mode opt-in should consider outside submitters #655
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
seanpdoyle
force-pushed
the
form-mode-bugfix
branch
from
July 29, 2022 21:17
b325343
to
09f89ea
Compare
seanpdoyle
changed the title
Bugfix: Form Mode opt-in handle outside submitters
Bugfix: Form Mode opt-in should consider outside submitters
Jul 29, 2022
Prior to this commit, the `Session.formElementIsNavigatable` method checked for the closest `<form>` element ancestor to its `element` argument. Unfortunately, checking for an ancestor form is an incomplete solution, since form controls can exist outside of the `<form>` elsewhere in the document and reference the form through their [`[form]`][form-attr] attributes. This commit incorporates a check for that into the `Session.formElementIsNavigatable` method. Since that method is only ever called on a submission's `submitter` argument after it's been verified to be present, this commit changes the signature to expect an `element` (by omitting the `?` modifier) and renames the method to `submitterIsNavigatable`. [form-attr]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input#form
seanpdoyle
force-pushed
the
form-mode-bugfix
branch
from
July 29, 2022 21:19
09f89ea
to
3ae1d46
Compare
seanpdoyle
added a commit
to seanpdoyle/turbo
that referenced
this pull request
Jul 30, 2022
Follow-up to hotwired#655 Follow-up to hotwired#419 This commit splits out a `form_mode_tests.ts` module separate from `form_submission_tests.ts`, along with a `form_mode.html` fixture file. Next, add test fixtures and test coverage for more thorough coverage of form mode, namely scenarios that submit a form without a submitter (for example, typing into an `<input type="text">` and pressing <kbd>enter</kbd>. Next, the `Turbo.setFormMode()` should be particular about its argument's value. This commit introduces a `FormMode = "on" | "off" | "optin"` type. Finally, rename `submitterIsNavigatable` to `submissionIsNavigatable`, and pass the `HTMLFormElement` and optional `HTMLElement` as a pair of arguments.
seanpdoyle
added a commit
to seanpdoyle/turbo
that referenced
this pull request
Jul 30, 2022
Follow-up to hotwired#655 Follow-up to hotwired#419 This commit splits out a `form_mode_tests.ts` module separate from `form_submission_tests.ts`, along with a `form_mode.html` fixture file. Next, add test fixtures and test coverage for more thorough coverage of form mode, namely scenarios that submit a form without a submitter (for example, typing into an `<input type="text">` and pressing <kbd>enter</kbd>. Next, the `Turbo.setFormMode()` should be particular about its argument's value. This commit introduces a `FormMode = "on" | "off" | "optin"` type. Finally, rename `submitterIsNavigatable` to `submissionIsNavigatable`, and pass the `HTMLFormElement` and optional `HTMLElement` as a pair of arguments.
seanpdoyle
added a commit
to seanpdoyle/turbo
that referenced
this pull request
Jul 30, 2022
Follow-up to hotwired#655 Follow-up to hotwired#419 This commit splits out a `form_mode_tests.ts` module separate from `form_submission_tests.ts`, along with a `form_mode.html` fixture file. Next, add test fixtures and test coverage for more thorough coverage of form mode, namely scenarios that submit a form without a submitter (for example, typing into an `<input type="text">` and pressing <kbd>enter</kbd>. Next, the `Turbo.setFormMode()` should be particular about its argument's value. This commit introduces a `FormMode = "on" | "off" | "optin"` type. Finally, rename `submitterIsNavigatable` to `submissionIsNavigatable`, and pass the `HTMLFormElement` and optional `HTMLElement` as a pair of arguments.
seanpdoyle
added a commit
to seanpdoyle/turbo
that referenced
this pull request
Jul 30, 2022
Follow-up to hotwired#655 Follow-up to hotwired#419 This commit splits out a `form_mode_tests.ts` module separate from `form_submission_tests.ts`, along with a `form_mode.html` fixture file. Next, add test fixtures and test coverage for more thorough coverage of form mode, namely scenarios that submit a form without a submitter (for example, typing into an `<input type="text">` and pressing <kbd>enter</kbd>. Next, the `Turbo.setFormMode()` should be particular about its argument's value. This commit introduces a `FormMode = "on" | "off" | "optin"` type. Finally, rename `submitterIsNavigatable` to `submissionIsNavigatable`, and pass the `HTMLFormElement` and optional `HTMLElement` as a pair of arguments.
seanpdoyle
added a commit
to seanpdoyle/turbo
that referenced
this pull request
Jul 30, 2022
Follow-up to hotwired#655 Follow-up to hotwired#419 This commit splits out a `form_mode_tests.ts` module separate from `form_submission_tests.ts`, along with a `form_mode.html` fixture file. Next, add test fixtures and test coverage for more thorough coverage of form mode, namely scenarios that submit a form without a submitter (for example, typing into an `<input type="text">` and pressing <kbd>enter</kbd>. Next, the `Turbo.setFormMode()` should be particular about its argument's value. This commit introduces a `FormMode = "on" | "off" | "optin"` type. Finally, rename `submitterIsNavigatable` to `submissionIsNavigatable`, and pass the `HTMLFormElement` and optional `HTMLElement` as a pair of arguments.
dhh
pushed a commit
that referenced
this pull request
Jul 31, 2022
Follow-up to #655 Follow-up to #419 This commit splits out a `form_mode_tests.ts` module separate from `form_submission_tests.ts`, along with a `form_mode.html` fixture file. Next, add test fixtures and test coverage for more thorough coverage of form mode, namely scenarios that submit a form without a submitter (for example, typing into an `<input type="text">` and pressing <kbd>enter</kbd>. Next, the `Turbo.setFormMode()` should be particular about its argument's value. This commit introduces a `FormMode = "on" | "off" | "optin"` type. Finally, rename `submitterIsNavigatable` to `submissionIsNavigatable`, and pass the `HTMLFormElement` and optional `HTMLElement` as a pair of arguments.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prior to this commit, the
Session.formElementIsNavigatable
methodchecked for the closest
<form>
element ancestor to itselement
argument. Unfortunately, checking for an ancestor form is an incomplete
solution, since form controls can exist outside of the
<form>
elsewhere in the document and reference the form through their
[form]
attributes.This commit incorporates a check for that into the
Session.formElementIsNavigatable
method. Since that method is onlyever called on a submission's
submitter
argument after it's beenverified to be present, this commit changes the signature to expect an
element
(by omitting the?
modifier) and renames the method tosubmitterIsNavigatable
.