mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 03:06:53 +08:00
DEV: Reduce width calculations for SK dropdowns (#18263)
Previously we were calculating both the minimum and maximum widths for SK dropdowns using this Popper modifier. The max. width calculation was causing issues with dropdowns in Firefox and was also sluggish when rendering. This switches to using CSS calculations for max. widths. It adds a 600px global maximum and targeted maximums for the category composer dropdown and the bookmark list dropdowns.
This commit is contained in:
@ -940,7 +940,7 @@ export default Component.extend(
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "sameWidth",
|
||||
name: "minWidth",
|
||||
enabled: window.innerWidth > 450,
|
||||
phase: "beforeWrite",
|
||||
requires: ["computeStyles"],
|
||||
@ -949,24 +949,12 @@ export default Component.extend(
|
||||
state.rects.reference.width,
|
||||
220
|
||||
)}px`;
|
||||
|
||||
if (state.rects.reference.width >= 300) {
|
||||
state.styles.popper.maxWidth = `${state.rects.reference.width}px`;
|
||||
} else {
|
||||
state.styles.popper.maxWidth = "300px";
|
||||
}
|
||||
},
|
||||
effect: ({ state }) => {
|
||||
state.elements.popper.style.minWidth = `${Math.max(
|
||||
state.elements.reference.offsetWidth,
|
||||
220
|
||||
)}px`;
|
||||
|
||||
if (state.elements.reference.offsetWidth >= 300) {
|
||||
state.elements.popper.style.maxWidth = `${state.elements.reference.offsetWidth}px`;
|
||||
} else {
|
||||
state.elements.popper.style.maxWidth = "300px";
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
|
Reference in New Issue
Block a user