Skip to content

fix validation skipping#60

Open
wynn987 wants to merge 2 commits into
choonkeat:mainfrom
wynn987:fix-validation-skipping
Open

fix validation skipping#60
wynn987 wants to merge 2 commits into
choonkeat:mainfrom
wynn987:fix-validation-skipping

Conversation

@wynn987

@wynn987 wynn987 commented Apr 22, 2026

Copy link
Copy Markdown

problem: users are able to bypass invalid states in the field settings by creating a new input with valid state

video shows

  • create an input with no label, cant submit
  • create an input with label, can submit even tho above input still invalid
bug.mov

same thing for dup checks

  • input with dup name is invalid
  • but adding another valid input after that is valid
emailbug.mov

after fix

actions will be disabled if field settings are invalid

for dup

fixdup.mov

for empty

afterfix.mov

@netlify

netlify Bot commented Apr 22, 2026

Copy link
Copy Markdown

Deploy Preview for tiny-form-fields ready!

Name Link
🔨 Latest commit 6948ecf
🔍 Latest deploy log https://app.netlify.com/projects/tiny-form-fields/deploys/69f809080c45bf0008791a9d
😎 Deploy Preview https://deploy-preview-60--tiny-form-fields.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Comment thread src/Main.elm Outdated
Comment thread src/Main.elm

else
[ Attr.pattern ".*" ]
[ Attr.pattern ".+" ]

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

more accurate since we do want them to fill this in (it is a required field even without the pattern)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Makes sense — .+ enforces non-empty even with no other constraint. Good.

Comment thread src/Main.elm
div [ class "tff-error-text" ] [ text "Question titles must be unique in a form" ]

else if isEmptyLabel then
div [ class "tff-error-text" ] [ text "Question title cannot be empty" ]

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

since we show err message for duplicate, why not also empty

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Agreed — matching the duplicate-label message keeps the inline feedback consistent.

@choonkeat

choonkeat commented May 2, 2026

Copy link
Copy Markdown
Owner

Tff Agent Chat.pdf

Discuss

Note: in a conversation, the human speech bubbles would be more noteworthy than the agent's speech bubbles

Comment thread src/Main.elm
, Cmd.none
)
( Just prevIndex, _ ) ->
if selectedFieldIsInvalid model then

@wynn987 wynn987 May 4, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

i kept the if selectedFieldIsInvalid model then and added an animation if user tries to click away because i think its still a better ux than allowing them to close the tab and not understand why the form is invalid

the scattering of if statement is addressed in #60 (comment)

yellow.mov

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Agree the animate-and-scroll beats silently letting them close a broken field. One gap: this guard only checks empty/duplicate, but the new form gate also catches ChooseMultiple min/max — so a min/max error blocks submission with no field highlight. Can we drive this guard from the same rule source so they can't drift?

Comment thread src/Main.elm
, value (Json.Encode.encode 0 (encodeFormFields model.formFields))
]
[]
:: viewEditorValidationGate model.formFields

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

validate form on model update instead of only scattering if selectedFieldIsInvalid

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Like moving to a central editorFormValidity instead of scattering. Since it now knows more rules than selectedFieldIsInvalid, can selectedFieldIsInvalid be derived from it (filtered to the selected field)? Then there's one source of truth and the scattered call sites stay as thin UX wrappers.

Comment thread index.html
Comment on lines +302 to +305
app.ports.scrollIntoView.subscribe((id) => {
var el = document.getElementById(id);
if (el) el.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
});

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

on top of animating an invalid field, it scrolls to it

if selectedFieldIsInvalid model then
                        ( { model | viewMode = Editor { maybeAnimate = Just ( prevIndex, AnimateYellowFade ) } }
                        , Cmd.batch
                            [ Process.sleep animateFadeDuration
                                |> Task.perform (always (SetEditorAnimate Nothing))
                            , scrollIntoView ("tff-field-" ++ String.fromInt prevIndex)
                            ]
                        )

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Nice touch. One thing to confirm: the gate input is visually-hidden + aria-hidden, so when the browser blocks submit does its title message actually surface, or does focus land on an invisible element? Want to make sure the min/max case isn't a silent block.

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