[BREAKING] Align behavior with Primer guidance by default#81
Merged
joelhawksley merged 1 commit intomainfrom Mar 24, 2025
Merged
[BREAKING] Align behavior with Primer guidance by default#81joelhawksley merged 1 commit intomainfrom
joelhawksley merged 1 commit intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR aligns the auto-check element’s validation behavior with Primer guidance by shifting validation from every keystroke to occur on blur.
- In test/auto-check.js, tests are updated to trigger validation via blur events instead of keypress/input events.
- In src/auto-check-element.ts, the onlyValidateOnBlur getter is removed and the validation flow in handleChange and check functions is adjusted accordingly.
Reviewed Changes
Copilot reviewed 2 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/auto-check.js | Updated tests to simulate blur-triggered validation by removing the opt-in toggle and adding triggerBlur calls. |
| src/auto-check-element.ts | Removed the onlyValidateOnBlur getter and refactored conditional logic to rely on validateOnKeystroke and blur events. |
Files not reviewed (2)
- custom-elements.json: Language not supported
- examples/index.html: Language not supported
Comments suppressed due to low confidence (2)
test/auto-check.js:32
- The removal of the only-validate-on-blur attribute in the test markup means that behavior when the opt-in toggle is active is not covered. Add tests to cover both the default behavior and the case when the opt-in toggle is enabled.
<auto-check csrf="foo" src="/success">
src/auto-check-element.ts:209
- The onlyValidateOnBlur getter has been removed from the auto-check element but related inline comments and logic still reference the opt-in toggle behavior. Update documentation and comments to reflect this removal.
get onlyValidateOnBlur(): boolean {
Tip: If you use Visual Studio Code, you can request a review from Copilot before you push from the "Source Control" tab. Learn more
jonrohan
approved these changes
Mar 21, 2025
Member
jonrohan
left a comment
There was a problem hiding this comment.
Couple of questions:
- What cases do you think this might fall down in dotcom? Where might this break the ui?
- Will you take on migrating those instances?
Contributor
Author
|
@jonrohan I've already rolled out and tested the new behavior to every use-case in dotcom! I'm confident in moving forward with this change. |
This file contains hidden or 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
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.
Problem
Us folks working on improving the GitHub.com signup flow are looking to address a UX/a11y concern with the
auto-checkelement: it validates on every keystroke.Proposed solution
We should modify the behavior to align with https://primer.style/ui-patterns/forms/overview#inline-validation, which states:
This PR follows up on #76, introducing the new behavior as a breaking change, having validated it across dozens of use cases on GitHub.com.