Skip to content

[Bug]:  #746

@maclynn147

Description

@maclynn147

Bug description

tom-select.ts:2244 Uncaught TypeError: Failed to execute 'insertBefore' on 'Node': parameter 1 is not of type 'Node'.
at J.insertAtCaret (tom-select.ts:2244:10)
at J. (tom-select.ts:1858:9)
at R (utils.ts:87:5)
at J.addItem (tom-select.ts:1829:3)
at J.onOptionSelect (tom-select.ts:838:10)
at HTMLDivElement. (tom-select.ts:297:10)

Expected behavior

new TomSelect('#select-state',{
valueField: 'label',
labelField: 'label',
searchField: ['label','type'],
// fetch remote data
load: function(query, callback) {
var self = this;
if( self.loading > 1 ){
callback();
return;
}

		var url = 'https://whatcms.org/API/List';
		fetch(url)
			.then(response => response.json())
			.then(json => {
				callback(json.result.list);
				self.settings.load = null;
			}).catch(()=>{
				callback();
			});

	},
	// custom rendering function for options
	render: {
		option: function(item, escape) {
			return `<div class="py-2 d-flex">
						<div class="mb-1">
							<span class="h5">
								${ escape(item.label) }
							</span>
						</div>
				 		<div class="ms-auto">${ escape(item.type.join(', ')) }</div>
					</div>`;
		},
                   item: function(item, escape) {
                      console.log(item);
                   }
	},
});

Steps to reproduce

  1. Go to ...
  2. Click on ....
    ...
    X. See error

Additional context

  • OS: [e.g. iOS, Windows]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]
  • Device: [e.g. iPhone6]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions