Skip to content

Commit

Permalink
fix app freezes and can't focus to editor on restore page (#640)
Browse files Browse the repository at this point in the history
* fix app freezes and can't focus to editor on restore page

* fix hint does not appear for other inputs except the first input

---------

Co-authored-by: bugjt <@bugjt>
  • Loading branch information
bugjt authored Sep 23, 2024
1 parent 28a8fcf commit 6203d40
Showing 1 changed file with 16 additions and 28 deletions.
44 changes: 16 additions & 28 deletions ui/page/components/seed_restore_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,37 +313,27 @@ func (pg *SeedRestore) editorSeedsEventsHandler(gtx C) {
for i := 0; i < len(pg.seedEditors.editors); i++ {
editor := pg.seedEditors.editors[i]
text := editor.Edit.Editor.Text()

if gtx.Source.Focused(editor.Edit.Editor) {
if editor.Edit.Changed() || editor.Edit.Selected() {
seedEvent(i, text)
}

for {
event, ok := editor.Edit.Editor.Update(gtx)
if !ok {
break
}
switch event.(type) {
case widget.ChangeEvent:
seedEvent(i, text)

case widget.SubmitEvent:
if pg.openPopupIndex != -1 {
if len(pg.suggestions) > 0 {
pg.seedEditors.editors[i].Edit.Editor.SetText(pg.seedMenu[pg.selected].text)
}
if editor.Edit.Submitted() {
if pg.openPopupIndex != -1 {
if len(pg.suggestions) > 0 {
pg.seedEditors.editors[i].Edit.Editor.SetText(pg.seedMenu[pg.selected].text)
pg.seedClicked = true
}
}

// Handles Enter and Return keyboard events.
if i != defaultNumberOfSeeds {
gtx.Execute(key.FocusCmd{Tag: pg.seedEditors.editors[i+1].Edit.Editor})
pg.selected = 0
}
// Handles Enter and Return keyboard events.
if i != defaultNumberOfSeeds {
gtx.Execute(key.FocusCmd{Tag: pg.seedEditors.editors[i+1].Edit.Editor})
pg.selected = 0
}

if i == defaultNumberOfSeeds {
pg.selected = 0
pg.isLastEditor = true
}
if i == defaultNumberOfSeeds {
pg.selected = 0
pg.isLastEditor = true
}
}
}
Expand Down Expand Up @@ -385,11 +375,9 @@ func (pg *SeedRestore) layoutSeedMenu(gtx C, optionsSeedMenuIndex int) {
}

m := op.Record(gtx.Ops)
_, caretPos := pg.seedEditors.editors[pg.seedEditors.focusIndex].Edit.Editor.CaretPos()
inset.Layout(gtx, func(gtx C) D {
border := widget.Border{Color: pg.Theme.Color.Gray4, CornerRadius: values.MarginPadding5, Width: values.MarginPadding2}
if !pg.seedEditorChanged() && pg.nextcurrentCaretPosition != caretPos {
pg.nextcurrentCaretPosition = -1
if !pg.seedEditorChanged() {
return border.Layout(gtx, func(gtx C) D {
return pg.optionsMenuCard.Layout(gtx, func(gtx C) D {
gtx.Constraints.Min.X = gtx.Constraints.Max.X
Expand Down

0 comments on commit 6203d40

Please sign in to comment.