Skip to content

Commit 462f4db

Browse files
fix: correct alignment of buttons in mt-select (#903)
1 parent eadd0c4 commit 462f4db

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

.changeset/nice-nails-grin.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@shopware-ag/meteor-component-library": patch
3+
---
4+
5+
fix: mt-select button alignment
103 Bytes
Loading

packages/component-library/src/components/form/_internal/mt-select-base/mt-select-base.vue

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
/>
3434
</div>
3535

36-
<div class="mt-select__selection-indicators">
36+
<div class="mt-select__selection-indicators" :style="{ right: selectionIndicatorsRight }">
3737
<mt-loader v-if="isLoading" class="mt-select__select-indicator" size="16px" />
3838

3939
<button
@@ -177,16 +177,46 @@ export default defineComponent({
177177
data() {
178178
return {
179179
expanded: false,
180+
suffixWidth: 0,
180181
};
181182
},
182183
183184
computed: {
184185
mtFieldClasses(): { "has--focus": boolean } {
185186
return { "has--focus": this.expanded };
186187
},
188+
189+
selectionIndicatorsRight(): string {
190+
const baseRightPx = 16;
191+
const rightPx = baseRightPx + (this.suffixWidth || 0);
192+
return `${rightPx}px`;
193+
},
194+
},
195+
196+
mounted() {
197+
this.$nextTick(() => this.updateSuffixWidth());
198+
window.addEventListener("resize", this.updateSuffixWidth, { passive: true });
199+
},
200+
201+
beforeUnmount() {
202+
window.removeEventListener("resize", this.updateSuffixWidth);
187203
},
188204
189205
methods: {
206+
updateSuffixWidth() {
207+
// Find the suffix container to get the width
208+
const suffixElement = this.$el?.querySelector(
209+
".mt-block-field__block > .mt-field__addition:not(.is--prefix)",
210+
);
211+
212+
if (!suffixElement) {
213+
this.suffixWidth = 0;
214+
return;
215+
}
216+
217+
this.suffixWidth = suffixElement.offsetWidth;
218+
},
219+
190220
toggleExpand() {
191221
if (!this.expanded) {
192222
this.expand();

0 commit comments

Comments
 (0)