Skip to content

Update() is not being called every "tick" #212

@TLINDEN

Description

@TLINDEN

(I don't know if bubbletea uses the term tick, but I assume it, because the ELM model suggests so)

I have a weird issue: I wanted to have a blinking cursor in the filter input. This is my implementation:

func (m *FilterTable) getBlink() string {
	m.blink = !m.blink

	if m.blink {
		return "_"
	}

	return " "
}

// Add some info to the footer
func (m *FilterTable) updateFooter() {
	filter := ""

	if m.Table.GetIsFilterInputFocused() {
		filter = StyleFilter.Render(fmt.Sprintf("Enter filter [ESC: abort, Enter: finish]> %s%s",
			m.Table.GetCurrentFilter(),
			m.getBlink()))
	} else if m.Table.GetIsFilterActive() {
		filter = StyleFilter.Render(fmt.Sprintf("Filter: %s", m.Table.GetCurrentFilter()))
	}

	selected := m.Table.SelectedRows()

	m.Table = m.Table.WithStaticFooter(
		filter +
			fmt.Sprintf("                   selected rows: %d ", len(selected)) +
			"| " + StyleHelpHint.Render(HelpFooter))
}

Now, when I start entering a filter using the / key, just an _ appears, it doesn't blink. Only after I start entering letters, the blinking happens.

I also tried it with a counter. It only increments once the first letter has been entered in filter mode.

What's also interesting: if I delete the already filter so that it's empty, the blinking continues. So it seems the filter being empty on startup doesn't seem to be the cause.

I am calling the updateFooter() function unconditionally in Update() - so on every tick as I assumed. But by the looks of it, Update() is just not being called regularly unless I enter the first filter letter. Maybe there are no ticks or there's some condition in bubble-table which causes this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions