Skip to content

Commit

Permalink
fix(kselect): intialize element width to 100% [KHCP-12370]
Browse files Browse the repository at this point in the history
  • Loading branch information
portikM committed Jun 26, 2024
1 parent 22f855d commit 274b3d8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
39 changes: 30 additions & 9 deletions sandbox/pages/SandboxSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,28 @@
:links="inject('app-links', [])"
title="KSelect"
>
<div class="kselect-sandbox">
<KSelect
clearable
enable-filtering
:items="selectItems"
>
<template #selected-item-template="{ item }">
<div class="custom-selected-item-container">
<div class="title">
<KongIcon />
{{ item?.label }}
</div>
<KBadge v-if="item?.label.toLocaleLowerCase() === 'cats' || item?.label.toLocaleLowerCase() === 'dogs'">
{{ item?.label.toLocaleLowerCase() === 'cats' ? 'Feline' : 'Canine' }}
</KBadge>
</div>
</template>
</KSelect>

<div
v-if="false"
class="kselect-sandbox"
>
<!-- Examples -->
<SandboxTitleComponent
is-subtitle
Expand Down Expand Up @@ -442,16 +463,16 @@ onMounted(() => {
font-size: $kui-font-size-20;
}
}
}

.custom-selected-item-container {
display: flex;
justify-content: space-between;
width: 100%;
.custom-selected-item-container {
display: flex;
justify-content: space-between;
width: 100%;

.title {
display: flex;
gap: $kui-space-30;
}
.title {
display: flex;
gap: $kui-space-30;
}
}
</style>
4 changes: 3 additions & 1 deletion src/components/KSelect/KSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,9 @@ const value = computed({
})
const elementWidth = computed((): string => getSizeFromString(props.width || '100%'))
const actualElementWidth = ref<string>('') // the pixel value of the element width for KPop container
// the pixel value of the element width for KPop container
// initialize to 100% to prevent jumping when the element width is calculated
const actualElementWidth = ref<string>('100%')
const modifiedAttrs = computed(() => {
const $attrs = { ...attrs }
Expand Down

0 comments on commit 274b3d8

Please sign in to comment.