ember-power-select icon indicating copy to clipboard operation
ember-power-select copied to clipboard

Extending power select to add an onScroll function to the select actions

Open gspain-gavant opened this issue 4 years ago • 1 comments

Hello, I am trying to use vertical collection in the options component which calls for an onScroll function to add more options to the list. Extending the power select to add a function to the select actions so that I can update the select.loading etc does not seem to work for me as onScroll returns undefined on this.args.select.actions. Thanks.

power-select-infinity.ts

import PowerSelect, { PowerSelectArgs, Select, SelectActions } from 'ember-power-select/components/power-select';

interface InfinitySelectActions extends SelectActions {
    onScroll: (term: string) => void
}

export interface InfinitySelect extends Select {
    actions: InfinitySelectActions
}

export interface InfinityArgs extends PowerSelectArgs {
    onScroll?: (term: string, select: InfinitySelect) => any[] | PromiseProxy<any[]>
}

export default class PowerSelectInfinityComponent extends PowerSelect<InfinityArgs> {...}

power-select/options.ts

import OptionsComponent, { Args } from 'ember-power-select/components/power-select/options';
import { InfinitySelect } from '../power-select-infinity';
import layout from '../../templates/power-select/options';
import { setComponentTemplate } from '@ember/component';
import { action } from '@ember/object';

interface InfinityArgs extends Args {
    select: InfinitySelect
}

class PowerSelectInfinityOptionsComponent extends OptionsComponent<InfinityArgs> {
    @action
    onScroll() {
        const selectObject: InfinitySelect = this.args.select;
        this.args.select.actions.onScroll(selectObject);
    }
}
export default setComponentTemplate(layout, PowerSelectInfinityOptionsComponent);

gspain-gavant avatar Apr 13 '20 17:04 gspain-gavant

Have you manage to get this fixed? I am having the same issue trying to load more items.

crozarakamilla avatar Mar 28 '21 17:03 crozarakamilla