Skip to content

Commit e529126

Browse files
triv(modal): fix modal autocomplete
1 parent 3808541 commit e529126

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "django-smartbase-admin"
3-
version = "0.2.16"
3+
version = "0.2.17"
44
description = ""
55
authors = ["SmartBase <[email protected]>"]
66
readme = "README.md"

src/django_smartbase_admin/static/sb_admin/src/js/autocomplete.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@ export default class Autocomplete {
2323
choiceInput.setAttribute('data-autocomplete-data-id', choiceInput.getAttribute('data-autocomplete-data-id').replace('__prefix__', totalFormsCount))
2424
this.initAutocomplete(choiceInput, totalFormsCount)
2525
})
26-
event.target.querySelectorAll('.js-autocomplete-detail').forEach(item => {
27-
item.addEventListener('SBAutocompleteChange', (e) => {
28-
filterInputValueChangedUtil(e.target)
29-
})
30-
})
26+
this.handleDynamiclyAddedAutocomplete(event.target)
27+
})
28+
document.body.addEventListener('SBModalShown', () => {
29+
this.handleDynamiclyAddedAutocomplete(document.getElementById('sb-admin-modal'))
3130
})
32-
document.querySelectorAll('.js-autocomplete-detail').forEach(item => {
31+
this.handleDynamiclyAddedAutocomplete(document)
32+
}
33+
34+
handleDynamiclyAddedAutocomplete(el) {
35+
el.querySelectorAll('.js-autocomplete-detail').forEach(item => {
3336
filterInputValueChangedUtil(item)
3437
item.addEventListener('SBAutocompleteChange', (e) => {
3538
filterInputValueChangedUtil(e.target)

src/django_smartbase_admin/templates/sb_admin/partials/modal/modal_content.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ <h5 class="font-semibold">
5555
choiceElements.forEach((choiceInput) => {
5656
window.SBAdmin.autocomplete.initAutocomplete(choiceInput);
5757
})
58+
document.body.dispatchEvent(new Event('SBModalShown'));
5859
})();
5960
</script>
6061
{% endblock %}

0 commit comments

Comments
 (0)