Skip to content
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

feat: check for form class/id #742

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dbajpeyi
Copy link
Collaborator

Reviewer:
Asana:

Description

Steps to test

@dbajpeyi dbajpeyi force-pushed the dbajpeyi/feat/check-class-and-id branch 6 times, most recently from 4d068f7 to 5a30f96 Compare January 28, 2025 08:20
@dbajpeyi dbajpeyi force-pushed the dbajpeyi/feat/check-class-and-id branch from 5a30f96 to 1c5552f Compare January 28, 2025 08:21
if (formLikeContainer) {
const containerInputs = formLikeContainer.querySelectorAll(this.matching.cssSelector('formInputsSelector'));
const submitButtons = formLikeContainer.querySelectorAll(this.matching.cssSelector('submitButtonSelector'));
if (containerInputs.length <= this.options.maxInputsPerForm && submitButtons.length > 0) {
Copy link
Member

Choose a reason for hiding this comment

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

I think you might still need to check for && inputs.length > 1 to avoid getting trapped in something like .class-form-row.

Suggested change
if (containerInputs.length <= this.options.maxInputsPerForm && submitButtons.length > 0) {
if (containerInputs.length <= this.options.maxInputsPerForm && inputs.length > 1 && submitButtons.length > 0) {

And you'll need recursion in that case. Adding the submit button requirement can also be revisited. Some forms might not have the submit button at all, or it can be some div.

But overall this seems directionally correct. Nice work!

// Try using closest() with form-like selectors
const formSelectors = [
// Explicit forms first
'form:not([role=search])',
Copy link
Member

Choose a reason for hiding this comment

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

If the input has a parent form, you'd get it with input.form, so this is redundant.

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.

2 participants