func()

in pkg/selector/outputs/sortingView.go [193:228]


func (m sortingModel) update(msg tea.Msg) (sortingModel, tea.Cmd) {
	var cmd tea.Cmd
	var cmds []tea.Cmd

	switch msg := msg.(type) {
	case tea.KeyMsg:
		switch msg.String() {
		case "down":
			if m.shorthandList.Index() == len(m.shorthandList.Items())-1 {
				// focus text input and hide cursor in shorthand list
				m.shorthandList.Select(len(m.shorthandList.Items()))
				m.sortTextInput.Focus()
			}
		case "up":
			if m.sortTextInput.Focused() {
				// go back to list from text input
				m.shorthandList.Select(len(m.shorthandList.Items()))
				m.sortTextInput.Blur()
			}
		case "tab":
			m.isDescending = !m.isDescending
		}

		if m.sortTextInput.Focused() {
			m.sortTextInput, cmd = m.sortTextInput.Update(msg)
			cmds = append(cmds, cmd)
		}
	}

	if !m.sortTextInput.Focused() {
		m.shorthandList, cmd = m.shorthandList.Update(msg)
		cmds = append(cmds, cmd)
	}

	return m, tea.Batch(cmds...)
}