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

Get item on labelRenderer? #363

Open
alvarotrigo opened this issue Oct 31, 2024 · 1 comment
Open

Get item on labelRenderer? #363

alvarotrigo opened this issue Oct 31, 2024 · 1 comment

Comments

@alvarotrigo
Copy link

alvarotrigo commented Oct 31, 2024

It'd be nice to be able to get the DOM item on the labelRenderer callback.
So we can apply modifications to it if we need to.

Right now I'm doing the following, but when scrolling up & down very fast it won't find the optionItem by the data-visible-index class. I guess because probably it's not yet created on the DOM.

labelRenderer: sampleLabelRenderer,
selectedLabelRenderer: sampleLabelRenderer

function sampleLabelRenderer(data) {
            let prefix = '';

            if (!data.isCurrentNew && !data.isNew) {
                var optionItem = document.querySelector('.vscomp-option[data-visible-index="'+data.visibleIndex+'"]');

                //fails to get the item
                if(!optionItem){
                    console.error("sale...");
                    console.log(data.label);
                    return `${prefix}${data.label}`;
                }
                console.log("vaa...");

               
            } else {

            }
            return `<span style="${styles}">${prefix}${data.label}</span>`;
}
@alvarotrigo
Copy link
Author

So right now I haven't found a reliable way to get the item on the labelRenderer callback

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