bombshell-dev / clack

Effortlessly build beautiful command-line apps
https://clack.cc
5.53k stars 90 forks source link

[Bug] Initial value array is modified #63

Closed banjo closed 1 year ago

banjo commented 1 year ago

Environment

Describe the bug I stumbled on some strange side effects, apparently the array that is passed in to initialValue is modified in a multiselect if you check in other values than the one you passed in to initialValue

To Reproduce

  1. Create a multi-select prompt
  2. Create an appropriate array with e.g. 3 values to use as options.
  3. Create another array with 2 of the same values and use as initialValue.
  4. Select the third value in the prompt.
  5. The initialValue array will be modified.

Expected behavior The array should not be mutated.

ulken commented 1 year ago

That is unexpected, indeed. I'll have a look at your PR.

ulken commented 1 year ago

Cross-posting for reference: https://github.com/natemoo-re/clack/pull/64#issuecomment-1435941615