carbon-fields icon indicating copy to clipboard operation
carbon-fields copied to clipboard

Removing the last item in a multiselect creates a map error in the console.

Open dtracey-fi opened this issue 1 year ago • 2 comments

Version

  • Carbon Fields: 3.6.2
  • WordPress: 5.4.1
  • PHP: 8.0

Expected Behavior

The user should be able to add all options to the multiselect field, and then remove them all.

Actual Behavior

Upon removing the last item in the multiselect, an error appears in the console, and the last item isn't removed.

Uncaught TypeError: Cannot read properties of null (reading 'map') at Object.onChange (core.min.js?ver=3.6.2:1:349535) at n.value (core.min.js?ver=3.6.2:1:348174) at e.onChange (core.min.js?ver=3.6.2:1:347471) at r.onChange (core.min.js?ver=3.6.2:1:322858) at r.removeValue (core.min.js?ver=3.6.2:1:324239) at onClick (core.min.js?ver=3.6.2:1:341192) at Object.Xa (react-dom.min.js?ver=18.2.0:10:105741) at B (react-dom.min.js?ver=18.2.0:10:10501

Container definition

Field::make('multiselect', 'test', 'Options')->add_options([
					'one' => 'One',
					'two' => "Two",
				]),

Steps to Reproduce the Problem

  1. Add One and Two to the multiselect field.
  2. Remove One and Two from the multiselect field.

dtracey-fi avatar Nov 26 '23 22:11 dtracey-fi

Any updates on this?

henrik-dons avatar Feb 02 '24 18:02 henrik-dons

Looks to be a duplicate of https://github.com/htmlburger/carbon-fields/issues/1182

Also waiting for an update on this please.

Youdaman avatar Mar 13 '24 06:03 Youdaman

Join this and waiting for updates...

paul-brain avatar Jul 20 '24 06:07 paul-brain

Fixed here: https://github.com/htmlburger/carbon-fields/commit/0103f0da9cac6ab9adfc067eb9fbacc4690f5b0b It will be included in next release

atanas-vasilev-dev avatar Jul 24 '24 06:07 atanas-vasilev-dev

Wow, that is a much needed fix for me. Looking anxiously for this release.

martin-neumann-gurus avatar Jul 26 '24 13:07 martin-neumann-gurus

The fix for this issue is now released in https://github.com/htmlburger/carbon-fields/releases/tag/v3.6.5

atanas-vasilev-dev avatar Jul 31 '24 08:07 atanas-vasilev-dev