mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-07-09 06:15:14 +02:00
Merge pull request #539 from eitchtee/dev
fix(tom-select): dropdown covers select field when height increases
This commit is contained in:
@@ -4,6 +4,15 @@ import '../styles/_tom-select.scss'
|
|||||||
|
|
||||||
|
|
||||||
window.TomSelect = function createDynamicTomSelect(element) {
|
window.TomSelect = function createDynamicTomSelect(element) {
|
||||||
|
const schedulePopperUpdate = function (instance) {
|
||||||
|
// Wait for TomSelect DOM updates before recalculating dropdown position.
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
if (instance.popper) {
|
||||||
|
instance.popper.update();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// Basic configuration
|
// Basic configuration
|
||||||
const config = {
|
const config = {
|
||||||
plugins: {},
|
plugins: {},
|
||||||
@@ -27,10 +36,16 @@ window.TomSelect = function createDynamicTomSelect(element) {
|
|||||||
this.popper = Popper.createPopper(this.control, this.dropdown, {
|
this.popper = Popper.createPopper(this.control, this.dropdown, {
|
||||||
placement: "bottom-start",
|
placement: "bottom-start",
|
||||||
modifiers: [
|
modifiers: [
|
||||||
|
{
|
||||||
|
name: "offset",
|
||||||
|
options: {
|
||||||
|
offset: [0, 4],
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "sameWidth",
|
name: "sameWidth",
|
||||||
enabled: true,
|
enabled: true,
|
||||||
fn: ({state}) => {
|
fn: ({ state }) => {
|
||||||
state.styles.popper.width = `${state.rects.reference.width}px`;
|
state.styles.popper.width = `${state.rects.reference.width}px`;
|
||||||
},
|
},
|
||||||
phase: "beforeWrite",
|
phase: "beforeWrite",
|
||||||
@@ -48,8 +63,17 @@ window.TomSelect = function createDynamicTomSelect(element) {
|
|||||||
|
|
||||||
},
|
},
|
||||||
onDropdownOpen: function () {
|
onDropdownOpen: function () {
|
||||||
this.popper.update();
|
schedulePopperUpdate(this);
|
||||||
}
|
},
|
||||||
|
onItemAdd: function () {
|
||||||
|
schedulePopperUpdate(this);
|
||||||
|
},
|
||||||
|
onItemRemove: function () {
|
||||||
|
schedulePopperUpdate(this);
|
||||||
|
},
|
||||||
|
onClear: function () {
|
||||||
|
schedulePopperUpdate(this);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (element.dataset.checkboxes === 'true') {
|
if (element.dataset.checkboxes === 'true') {
|
||||||
|
|||||||
Reference in New Issue
Block a user