Skip to content

Commit 57e5aa1

Browse files
committed
Bug fix
Fix a bug where the TextField cursor would jump to the end when adding a new character at the beginning of the text. This was more noticeable when editing.
1 parent 6b4c268 commit 57e5aa1

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

App/UnderstandingCoreData/Core Data/Item+CoreDataClass.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ extension Item {
1919
// }
2020

2121
var nameString: String {
22-
name ?? "Unknown Item"
22+
get { name ?? "" }
23+
set { name = newValue }
2324
}
2425

2526
var itemHistory: [History] {

App/UnderstandingCoreData/Views/ItemDetailEditForm.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct ItemDetailEditForm: View {
1515
var body: some View {
1616
Form {
1717
Section(header: Text("Item Info")) {
18-
TextField("Name", text: .init($item.name, ""))
18+
TextField("Name", text: $item.nameString)
1919
ThemePicker(selection: $item.themeEnum)
2020
}
2121
}

0 commit comments

Comments
 (0)