onChange not being called on List when entry is already selected

Open Beginner friendly
#22 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
lua
Domain
frontend

Research direction

Locate the List component implementation and trace the entry-click path that decides selection state, comparing where onChange fires for selection versus deselection. The issue names onChange and the private _onEntryClick, but not a file, so start by searching the repository for those identifiers. Reproduce with the supplied view:AddList snippet; done means clicking an already-selected entry invokes onChange with selected false and the same event contract as selection.

Written by the indexing model from the issue text.

Description

bug

I'm trying to use the List but one issue I'm hitting is that onChange isn't being called when the entry is already selected (to do a deselect). Not sure why, but here's a snippet of the code that I have:

view:AddList({
    maxSelected = #Regions.LIST,
    entries = entries,
    _onEntryClick = function(_, id, selected)
        log("onentry")
    end,
    onChange = function(_, id, selected, eventType)
        log("onchange")
    end,
})

The _onEntryClick does fire when I click on an already selected entry so that works as a workaround for now, but it's a private method so not great to use. It looks like onChange should be called on a deselection too based on the List code.

Dominant language
Lua
Stars
6
Forks
4
Avg merge
2d 7h
Merged PRs (30d)
18

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from PrettyRS/prettyui

All issues in PrettyRS/prettyui

Similar issues

More Lua issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.