Skip to content

Commit

Permalink
fix(select-tree): 修正下拉宽度变更
Browse files Browse the repository at this point in the history
  • Loading branch information
blankzhang authored and blankzhang committed Jul 24, 2023
1 parent 719023d commit d1016c8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
11 changes: 5 additions & 6 deletions components/select-tree/selectTree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ export default defineComponent({
watch(isOpened, () => {
emit('visibleChange', unref(isOpened));
// trigger 在mounted 之后可能会改变
if (isOpened.value && triggerDomRef.value) {
triggerWidth.value = triggerDomRef.value.$el.offsetWidth;
}
});
const handleChange = () => {
Expand Down Expand Up @@ -341,12 +346,6 @@ export default defineComponent({
const triggerDomRef = ref();
const triggerWidth = ref(0);
onMounted(() => {
if (triggerDomRef.value) {
triggerWidth.value = triggerDomRef.value.$el.offsetWidth;
}
});
const dropdownStyle = computed(() => {
const style: CSSProperties = {};
if (triggerWidth.value) {
Expand Down
7 changes: 1 addition & 6 deletions components/select/select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export default defineComponent({
watch(isOpenedRef, () => {
emit('visibleChange', unref(isOpenedRef));
// trigger 在mounted 之后可能会改变
if (isOpenedRef.value && triggerRef.value) {
triggerWidth.value = triggerRef.value.$el.offsetWidth;
}
Expand Down Expand Up @@ -373,12 +374,6 @@ export default defineComponent({
}
};
onMounted(() => {
if (triggerRef.value) {
triggerWidth.value = triggerRef.value.$el.offsetWidth;
}
});
const dropdownStyle = computed(() => {
const style: CSSProperties = {};
if (triggerWidth.value) {
Expand Down
6 changes: 3 additions & 3 deletions docs/.vitepress/components/selectTree/common.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ function createLabel(level) {
export default {
setup() {
const data = ref([]);
setTimeout(()=>{
data.value = createData(4);
})
setTimeout(() => {
data.value = createData(4);
});
return {
data,
};
Expand Down

0 comments on commit d1016c8

Please sign in to comment.