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

classNames.itemChoice is undefined in callbackOnCreateTemplates choice #1147

Open
greatshieh opened this issue Feb 29, 2024 · 0 comments
Open

Comments

@greatshieh
Copy link

When I called callbackOnCreateTemplates to custom template.

choice: (classNames,data) => {
return templates(
	`<div class="${classNames.item} ${
		classNames.itemChoice
	} ${
		data.disabled
			? classNames.itemDisabled
			: classNames.itemSelectable
	}" data-choice ${
		data.disabled
			? 'data-choice-disabled aria-disabled="true"'
			: "data-choice-selectable"
	} data-id="${data.id}" data-value="${data.value}" ${
		data.groupId && data.groupId > 0
			? 'role="treeitem"'
			: 'role="option"'
	}><span style="margin-right:10px; width:12px; height:12px; background-color:${
		data?.customProperties?.color
	};display:inline-block;vertical-align:middle;margin-top:-2px;"></span>${
		data.label
	}</div>`
);
},

But it worked when the code changed to

choice: ({classNames},data) => {
return templates(
	`<div class="${classNames.item} ${
		classNames.itemChoice
	} ${
		data.disabled
			? classNames.itemDisabled
			: classNames.itemSelectable
	}" data-choice ${
		data.disabled
			? 'data-choice-disabled aria-disabled="true"'
			: "data-choice-selectable"
	} data-id="${data.id}" data-value="${data.value}" ${
		data.groupId && data.groupId > 0
			? 'role="treeitem"'
			: 'role="option"'
	}><span style="margin-right:10px; width:12px; height:12px; background-color:${
		data?.customProperties?.color
	};display:inline-block;vertical-align:middle;margin-top:-2px;"></span>${
		data.label
	}</div>`
);
},

All attr of classNames are undefined. But they are worked in item.

item: (classNames, data) => {
	return templates(
		`<div class="${classNames.item} ${
			data.highlighted
				? classNames.highlightedState
				: classNames.itemSelectable
		}" data-item data-id="${data.id}" data-value="${
			data.value
		}" ${
			data.active ? 'aria-selected="true"' : ""
		}><span style="margin-right:10px; width:12px; height:12px; background-color:${
			data?.customProperties?.color
		};display:inline-block;vertical-align:middle;margin-top:-2px;"></span>${
			data.label
		}</div>`
	);
}

So, what is the right defined?

Thanks!

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