Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiselect - Cannot remove last item. #1258

Open
ShaneMuir opened this issue Oct 9, 2024 · 0 comments
Open

Multiselect - Cannot remove last item. #1258

ShaneMuir opened this issue Oct 9, 2024 · 0 comments

Comments

@ShaneMuir
Copy link

Version

  • Carbon Fields: ^3.6
  • WordPress: 6.6.2
  • PHP: 8.2

Expected Behavior

Please enter the expected behavior here
When clicking the remove button on the last option you'd expect the multiselect to be empty but we get a console error instead.

Actual Behavior

Please enter the actual, unexpected behavior here
Last item doesn't remove and console error logged.

draftJs.js:1 browsecSiteContentScript: data is not for auth
(anonymous) @ browsecSiteContentScript.js:1
postMessage
r @ draftJs.js:1
f.setImmediate @ draftJs.js:1
S @ vendor.min.js:49
P @ vendor.min.js:49
(anonymous) @ draftJs.js:1
h @ draftJs.js:1
a @ draftJs.js:1
postMessage
r @ draftJs.js:1
f.setImmediate @ draftJs.js:1
S @ vendor.min.js:49
L @ vendor.min.js:49
t.unstable_scheduleCallback @ vendor.min.js:49
mc @ vendor.min.js:39
Hl @ vendor.min.js:39
Bl @ vendor.min.js:39
Ac @ vendor.min.js:39
Dc.render.zc.render @ vendor.min.js:39
l @ metaboxes.min.js:1
(anonymous) @ metaboxes.min.js:1
(anonymous) @ vendor.min.js:16
lr @ vendor.min.js:16
(anonymous) @ vendor.min.js:16
uu @ vendor.min.js:16
f @ metaboxes.min.js:1
(anonymous) @ metaboxes.min.js:1
(anonymous) @ vendor.min.js:49
be @ core.min.js:12
(anonymous) @ post.php?post=3327&action=edit:2364
Show 1 more frame
Show lessUnderstand this warning
vendor.min.js:39 Uncaught TypeError: Cannot read properties of null (reading 'map')
    at Object.onChange (core.min.js:1:112317)
    at n.value (core.min.js:1:311799)
    at e.onChange (core.min.js:1:311096)
    at o.onChange (core.min.js:1:285026)
    at o.removeValue (core.min.js:1:286769)
    at onClick (core.min.js:1:303726)
    at Object.Le (vendor.min.js:39:16683)
    at Fe (vendor.min.js:39:16837)
    at vendor.min.js:39:35605
    at Tr (vendor.min.js:39:35699)

Container definition

// Please add your entire container defintion here so issues
// are easy to reproduce
Container::make('post_meta', __('Branch Details', 'tribus-branch-finder'))
            ->where('post_type', '=', 'branches')
            ->add_fields(
                array(
                    Field::make('text', 'branch_contact_number', __('Branch Contact Number', 'tribus-branch-finder')),
                    Field::make('map', 'branch_location', __('Branch Location', 'tribus-branch-finder'))
                        ->set_help_text(__('Drag the marker to set the exact location or enter the address below', 'tribus-branch-finder')),
                    Field::make('textarea', 'branch_full_address', __('Full Address', 'tribus-branch-finder'))
                        ->set_help_text(__('Enter the full address including street, town, and postcode.', 'tribus-branch-finder'))
                        ->set_attribute('placeholder', 'e.g., 158a Cromwell Road, London, SW7 4EJ'),
                    Field::make('text', 'branch_zone', __('Zone', 'tribus-branch-finder')),
                    Field::make('text', 'branch_region', __('Region', 'tribus-branch-finder')),
                    Field::make('text', 'branch_store_code', __('Store Code', 'tribus-branch-finder')),
                    Field::make('text', 'branch_store_number', __('Store Number', 'tribus-branch-finder')),
                    Field::make('text', 'branch_nutrio_ranging', __('Nutrio Ranging', 'tribus-branch-finder')),
                    Field::make('text', 'branch_nutrio_match', __('Nutrio Name Match', 'tribus-branch-finder')),
                    Field::make('text', 'branch_cluster_area', __('Cluster/Area', 'tribus-branch-finder')),
                    Field::make('text', 'branch_store_type', __('Store Type', 'tribus-branch-finder')),
                    Field::make('text', 'branch_name', __('Store Name', 'tribus-branch-finder')),
                    Field::make('text', 'branch_telephone', __('Telephone', 'tribus-branch-finder')),
                    Field::make('text', 'branch_store_manager', __('Store Manager', 'tribus-branch-finder')),
                    Field::make('multiselect', 'branch_store_products', __('Products', 'tribus-branch-finder'))
                        ->set_options(array(
                            'full_fat' => 'Full Fat',
                            'semi_skimmed' => 'Semi Skimmed',
                            'skimmed' => 'Skimmed',
                        ))
                        ->set_default_value([])
                        ->set_help_text('Select the products available in this store.')
                )
            );

Steps to Reproduce the Problem

  1. add items to multiselect
  2. try remove last item

Comments

Please add any other comments here
If I get time I'll try look into this issue and apply a fix PR but just raising the issue for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant