diff --git a/ember-power-select/src/components/power-select-multiple.hbs b/ember-power-select/src/components/power-select-multiple.hbs index 7ef1b92ed..a7504ec04 100644 --- a/ember-power-select/src/components/power-select-multiple.hbs +++ b/ember-power-select/src/components/power-select-multiple.hbs @@ -19,6 +19,7 @@ @highlightOnHover={{@highlightOnHover}} @typeAheadOptionMatcher={{@typeAheadOptionMatcher}} @destination={{@destination}} + @destinationElement={{@destinationElement}} @disabled={{@disabled}} @dropdownClass={{@dropdownClass}} @extra={{@extra}} diff --git a/ember-power-select/src/components/power-select.hbs b/ember-power-select/src/components/power-select.hbs index e8c59aacb..42e4baab8 100644 --- a/ember-power-select/src/components/power-select.hbs +++ b/ember-power-select/src/components/power-select.hbs @@ -16,6 +16,7 @@ {{/if}} ; selected?: any | PromiseProxy; destination?: string; + destinationElement?: HTMLElement; closeOnSelect?: boolean; renderInPlace?: boolean; preventScroll?: boolean; diff --git a/test-app/tests/integration/components/power-select/general-behaviour-test.js b/test-app/tests/integration/components/power-select/general-behaviour-test.js index 8c78dd66f..cc9b0d957 100644 --- a/test-app/tests/integration/components/power-select/general-behaviour-test.js +++ b/test-app/tests/integration/components/power-select/general-behaviour-test.js @@ -22,6 +22,7 @@ import PromiseProxyMixin from '@ember/object/promise-proxy-mixin'; import ArrayProxy from '@ember/array/proxy'; import ObjectProxy from '@ember/object/proxy'; import { TrackedArray } from 'tracked-built-ins'; +import { modifier } from 'ember-modifier'; const PromiseArrayProxy = ArrayProxy.extend(PromiseProxyMixin); const PromiseObject = ObjectProxy.extend(PromiseProxyMixin); @@ -1385,6 +1386,30 @@ module( .exists('Dropdown is rendered inside the destination element'); }); + test('The destination where the content is rendered can be customized by passing a `destinationElement=element`', async function (assert) { + assert.expect(2); + + this.numbers = numbers; + this.ref = modifier((element) => { + this.set('destinationElement', element); + }); + await render(hbs` + + {{option}} + +
+ `); + + assert + .dom('.ember-power-select-dropdown') + .doesNotExist('Dropdown is not rendered'); + + await clickTrigger(); + assert + .dom('.alternative-destination .ember-power-select-dropdown') + .exists('Dropdown is rendered inside the destination element'); + }); + test('[BUGFIX] When the component is open and it has a `search` action, if options get updated the highlighted items is reset', async function (assert) { assert.expect(2);