docs(state-management): add @FocusState guidance for single vs multi-field forms#25
Merged
EngOmarElsayed merged 2 commits intoAvdLee:mainfrom Feb 25, 2026
Conversation
Collaborator
EngOmarElsayed
left a comment
There was a problem hiding this comment.
Thanks for this PR and it looks good, I hope you are enjoying the skill
|
|
||
| - Use `@FocusState private var isFocused: Bool` when the view has a single focusable field. | ||
| - Use a `Hashable` enum optional value for multiple fields. | ||
| - Prefer an enum for readability and type safety when fields are known in advance. |
Collaborator
There was a problem hiding this comment.
what do you mean by this statement ?
Contributor
Author
There was a problem hiding this comment.
Actually is better to say something like: Prefer an enum for better readability and type safety when there are multiple fields.
I'll update it.
EngOmarElsayed
approved these changes
Feb 25, 2026
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.
Adds
@FocusStateguidance to the SwiftUI state management reference, covering when to use:What Changed
@FocusStatesection to state-management.mdIncluded examples for:
@FocusStateBool@FocusStateField? using a Hashable enumWhy
This fills a gap in the current state management reference with practical SwiftUI-specific guidance for focus handling, especially for form views with multiple inputs.
Test Notes
Docs-only change; no runtime tests required.