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

Bug | Select | Compomemnt #439

Open
naumcei opened this issue Aug 13, 2024 · 0 comments
Open

Bug | Select | Compomemnt #439

naumcei opened this issue Aug 13, 2024 · 0 comments

Comments

@naumcei
Copy link

naumcei commented Aug 13, 2024

Summary

There is a bug on dropdwon select, Please note that the removeOption is calling the setOption

Steps to Reproduce

In latest version 2.4.1

public removeOption(values: string | string[]) {
	const removeOption = (val: string, isArray = false) => {
		const hasOption = !!this.selectOptions.some(
			(el: ISingleOption) => el.val === val,
		);

		if (hasOption) {
			this.removeSelectOption(val, isArray);
			this.destroyOption(val);
			this.destroyOriginalOption(val);

			if (this.value === val) {
				this.value = null;

				this.eraseToggleTitle();
				this.eraseToggleIcon();
			}
		}
	};

	if (Array.isArray(values)) {
		values.forEach((val) => {
			removeOption(val, this.isMultiple);
		});
	} else {
		removeOption(values, this.isMultiple);
	}

	this.setNewValue();
}

The is a bug in the function

private setNewValue() {
	if (this.mode === 'tags') {
		this.setTagsItems();
	} else {
		console.log();

		if (this.value.length)
			this.toggleTextWrapper.innerHTML = this.stringFromValue();
		else this.toggleTextWrapper.innerHTML = this.placeholder;
	}
}
preline.js?v=d33b9117:4419 Uncaught TypeError: Cannot read properties of null (reading 'length')
    at _HSSelect.setNewValue (preline.js?v=d33b9117:4419:22)
    at _HSSelect.removeOption (preline.js?v=d33b9117:4613:10)
    ```


### Demo Link

\

### Expected Behavior

_No response_

### Actual Behavior

_No response_

### Screenshots

_No response_
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