nstudio / nstudio/nativescript-plugins

@nstudio/nativescript-checkbox: Toggle is being called twice when binding the checked to an attribute.

Open
#132 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

solution posted
Dominant language
TypeScript
Stars
55
Forks
42
Avg merge
49m
Merged PRs (30d)
1

Description

If you make it this way:

<template>
  <Page>
    <StackLayout
      orientation="vertical">
      <check-box
        v-for="(option, index) in options"
        :key="index"
        :text="option"
        :checked="index == selected"
        boxType="circle"
        @tap="selectOption(index)"
        @checkedChange="changed(index)"/>
    </StackLayout>
  </Page>
</template>

<script lang="coffee">

export default
  
  data: () ->
    {
      options: [
        "First"
        "Second"
        "Third"
        "Fourth"
      ]
      selected: null
    }

  methods:

    selectOption: (index) ->
      if this.selected == index
        this.selected = null
      else
        this.selected = index

    changed: (index) ->
      console.log "changed #{index}"

</script>

and click on an already selected option, you became able to select another one.

Contributor guide

No contributing guide indexed for this repository

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.

Research direction

Reproduce the behavior with the Vue template and checkbox bindings shown in the issue, then trace the plugin's checked and checkedChange handling. Done means clicking an already selected option does not invoke the toggle behavior twice or unexpectedly select another option.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.