-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: multiple fixes identified after adding it to external project
fixes multiple bugs found after implementing it into Slickgrid-Universal: - `setSelects` should work even after creating a new multiple-select dynamically from an empty select DOM element and providing an array to the `data` property - ms-drop DOM element should also be able to add a `name` attribute when its `name` option is provided - locale aren't loaded asynchronously anymore and shouldn't be either because that was causing the ms instance to longer be synchronous when it should - tooltip title values should be displayed with proper delimiter when provided - add new `minHeight` option since we already have a `maxHeight` option
- Loading branch information
1 parent
385b5c6
commit 5e78f68
Showing
11 changed files
with
226 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<div class="row mb-2"> | ||
<div class="col-md-12 title-desc"> | ||
<h2 class="bd-title"> | ||
Dynamically create Multiple-Select with Data collection | ||
<span class="float-end links"> | ||
Code <span class="fa fa-link"></span> | ||
<span class="small"> | ||
<a | ||
target="_blank" | ||
href="https://github.com/ghiscoding/multiple-select-vanilla/blob/main/demo/src/options/options08.html" | ||
>html</a | ||
> | ||
| | ||
<a target="_blank" href="https://github.com/ghiscoding/multiple-select-vanilla/blob/main/demo/src/options/options08.ts" | ||
>ts</a | ||
> | ||
</span> | ||
</span> | ||
</h2> | ||
<div class="demo-subtitle"> | ||
Dynamically create a Multiple-Select instance with <code>data</code> property. | ||
<br /> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div> | ||
<div class="mb-3 row"> | ||
<label class="col-sm-2"> Create </label> | ||
|
||
<div class="col-sm-10"> | ||
<button id="destroyBtn" class="btn btn-danger btn-sm">Destroy</button> | ||
<button id="createBtn" class="btn btn-primary btn-sm">Dynamically Create</button> | ||
</div> | ||
</div> | ||
|
||
<div class="mb-3 row"> | ||
<label class="col-sm-3 text-end">Use Select Option Label & Render HTML</label> | ||
|
||
<div class="col-sm-9"> | ||
<select id="select1" class="full-width"></select> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { multipleSelect, MultipleSelectInstance } from 'multiple-select-vanilla'; | ||
|
||
export default class Example { | ||
createBtnElm?: HTMLButtonElement | null; | ||
destroyBtnElm?: HTMLButtonElement | null; | ||
ms1?: MultipleSelectInstance; | ||
|
||
mount() { | ||
this.createBtnElm = document.querySelector('#createBtn'); | ||
this.destroyBtnElm = document.querySelector('#destroyBtn'); | ||
this.createBtnElm!.addEventListener('click', this.createMultipleSelect.bind(this)); | ||
this.destroyBtnElm!.addEventListener('click', this.destroyMultiSelect.bind(this)); | ||
} | ||
|
||
createMultipleSelect() { | ||
this.ms1 = multipleSelect('#select1', { | ||
name: 'my-select', | ||
single: false, | ||
useSelectOptionLabelToHtml: true, | ||
data: [ | ||
{ | ||
text: '<i class="fa fa-star"></i> January', | ||
value: 1, | ||
}, | ||
{ | ||
text: 'February', | ||
value: 2, | ||
}, | ||
{ | ||
text: 'March', | ||
value: 3, | ||
}, | ||
{ | ||
text: 'April', | ||
value: 4, | ||
}, | ||
{ | ||
text: 'May', | ||
value: 5, | ||
}, | ||
{ | ||
text: 'June', | ||
value: 6, | ||
}, | ||
{ | ||
text: 'July', | ||
value: 7, | ||
}, | ||
{ | ||
text: 'August', | ||
value: 8, | ||
}, | ||
{ | ||
text: 'September', | ||
value: 9, | ||
}, | ||
{ | ||
text: 'October', | ||
value: 10, | ||
}, | ||
{ | ||
text: 'November', | ||
value: 11, | ||
}, | ||
{ | ||
text: 'December', | ||
value: 12, | ||
}, | ||
], | ||
}) as MultipleSelectInstance; | ||
|
||
this.ms1.setSelects([1, 3, 4]); | ||
} | ||
|
||
destroyMultiSelect() { | ||
console.log('destroy'); | ||
this.ms1?.destroy(); | ||
this.ms1 = undefined; // remove detached element | ||
} | ||
|
||
unmount() { | ||
// destroy ms instance(s) to avoid DOM leaks | ||
this.destroyMultiSelect(); | ||
this.createBtnElm!.removeEventListener('click', this.createMultipleSelect.bind(this)); | ||
this.destroyBtnElm!.removeEventListener('click', this.destroyMultiSelect.bind(this)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,32 @@ | ||
import { MultipleSelectInstance, multipleSelect } from 'multiple-select-vanilla'; | ||
|
||
export default class Example { | ||
buildBtnElm?: HTMLButtonElement | null; | ||
destroyBtnElm?: HTMLButtonElement | null; | ||
ms1?: MultipleSelectInstance | null; | ||
|
||
mount() { | ||
this.buildBtnElm = document.querySelector('#buildBtn'); | ||
this.destroyBtnElm = document.querySelector('#destroyBtn'); | ||
this.destroyBtnElm!.addEventListener('click', this.destroyMultiSelect.bind(this)); | ||
this.buildBtnElm!.addEventListener('click', this.createMultipleSelect.bind(this)); | ||
|
||
this.ms1 = multipleSelect('select') as MultipleSelectInstance | null; | ||
} | ||
|
||
document.querySelector('#destroyBtn')!.addEventListener('click', () => { | ||
this.ms1?.destroy(); | ||
this.ms1 = null; // remove detached element | ||
}); | ||
createMultipleSelect() { | ||
this.ms1 = multipleSelect('select') as MultipleSelectInstance; | ||
} | ||
|
||
document.querySelector('#buildBtn')!.addEventListener('click', () => { | ||
this.ms1 = multipleSelect('select') as MultipleSelectInstance; | ||
}); | ||
destroyMultiSelect() { | ||
this.ms1?.destroy(); | ||
this.ms1 = null; // remove detached element | ||
} | ||
|
||
unmount() { | ||
// destroy ms instance(s) to avoid DOM leaks | ||
this.ms1?.destroy(); | ||
this.ms1 = undefined; | ||
this.destroyMultiSelect(); | ||
this.buildBtnElm!.removeEventListener('click', this.destroyMultiSelect.bind(this)); | ||
this.destroyBtnElm!.removeEventListener('click', this.createMultipleSelect.bind(this)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.