silverstripe / silverstripe-tagfield

Silverstripe module for editing tags (both in the CMS and other forms)
http://silverstripe.org/tag-field-module
BSD 3-Clause "New" or "Revised" License
57 stars 74 forks source link

StringTagField Disappears #283

Closed thejimu closed 7 months ago

thejimu commented 8 months ago

Module version(s) affected

2.11.2

Description

On stringtagfield after selecting an item the tagfield disappears with the following error in console: Uncaught TypeError: this.selectComponentRef.select is undefined

Also tried to install tagfield onto a fresh install but got the following composer error:

Could not find a matching version of package silverstripe/silverstripe-tagfield. Check the  
   package spelling, your version constraint and that the package is available in a stabilit  
  y which matches your minimum-stability (dev).

Edit: Disabled Lazy load, lazy loading produces no results. Edit 2: Enabling "canCreate" allows tagfield to work.

How to reproduce

$TagField = StringTagField::create(
    'AttributeSelect',
    'Attributes',
    $items,
    $this->Attributes
) 
->setShouldLazyLoad(false)
->setCanCreate(false)
->setDescription('Attributes that this filter should match to');
$fields->addFieldToTab('Root.Main', $TagField);

Possible Solution

canCreate=true is all good.

Additional Context

No response

Validations

GuySartorelli commented 8 months ago

I can't reproduce this bug in a fresh installation of silverstripe/installer.

Here's my page - I'm not sure if it matches what you have, because your "how to reproduce" doesn't provide a full code sample:

<?php

namespace {

    use SilverStripe\CMS\Model\SiteTree;
    use SilverStripe\TagField\StringTagField;

    class Page extends SiteTree
    {
        private static $db = [
            'Attributes' => 'Varchar',
        ];

        private static $has_one = [];

        public function getCMSFields()
        {
            $fields = parent::getCMSFields();
            $fields->removeByName('Tags');
            $fields->addFieldsToTab('Root.Main', [
                StringTagField::create(
                    'AttributeSelect',
                    'Attributes',
                    ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight'],
                    $this->Attributes
                )
                ->setShouldLazyLoad(false)
                ->setCanCreate(false)
            ]);
            return $fields;
        }
    }
}

after selecting an item the tagfield disappears

As you can see I have no problem adding or removing items in the StringTagField: Screencast from 08-03-24 10:10:29.webm

Can you please provide more reproduction steps? If you did not in fact reproduce this in a fresh installation of silverstripe/installer, can you please try that?

GuySartorelli commented 7 months ago

I can't reproduce this and there has been no further information about how to reproduce it - so I'm going to close this. If someone can provide more detailed reproduction steps I can reopen it and investigate further.

sb-relaxt-at commented 6 months ago

After upgrading one of our websites, we face the same issue using tag field 2.11.2 in Silverstripe 4. From my understanding this line causes the issue:

https://github.com/silverstripe/silverstripe-tagfield/blob/3f69c0d9f91b099fb843ae5b505ade7909fe9fc4/client/src/components/TagField.js#L39

this.selectedComponentRef.select is undefined, I suppose it should be this.selectComponentRef.wrapper as this is defined and references the dom element.

Edit: Downgrading to 2.11.1 resolves this issue.

GuySartorelli commented 6 months ago

@sb-relaxt-at Thank you for that context - but I still don't have any reproduction steps that I can follow to actually see this bug for myself. Can you please provide me with reproduction steps?

I'll leave this issue closed until I have steps I can follow to reliably reproduce the bug.