Skip to content

Commit ecb0970

Browse files
authored
🔀 Merge pull request #1928 from shumittaher/bugcols
Fixed #1927 When a section's displayData.cols exceeds the page's active grid column count, the section's col-span is now clamped to the page column count
2 parents 8d52976 + 45dcc7c commit ecb0970

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

docs/configuring.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ For more info, see the **[Authentication Docs](/docs/authentication.md)**
306306
**`collapsed`** | `boolean` | _Optional_ | If true, the section will be collapsed initially, and will need to be clicked to open. Useful for less regularly used, or very long sections. Defaults to `false`
307307
**`cutToHeight`** | `boolean` | _Optional_ | By default, sections will fill available space. Set this option to true to match section height with content height
308308
**`rows`** | `number` | _Optional_ | Height of the section, specified as the number of rows it should span vertically, e.g. `2`. Defaults to `1`. Max is `5`.
309-
**`cols`** | `number` | _Optional_ | Width of the section, specified as the number of columns the section should span horizontally, e.g. `2`. Defaults to `1`. Max is `5`.
309+
**`cols`** | `number` | _Optional_ | Width of the section, specified as the number of columns the section should span horizontally, e.g. `2`. Defaults to `1`. Max is `6`. Will be clamped to the page's active column count so that a section never exceeds the available grid width.
310310
**`itemSize`** | `string` | _Optional_ | Specify the size for items within this group, either `small`, `medium` or `large`. Note that this will override any settings specified through the UI
311311
**`color`** | `string` | _Optional_ | A custom accent color for the section, as a hex code or HTML color (e.g. `#fff`)
312312
**`customStyles`** | `string` | _Optional_ | Custom CSS properties that should be applied to that section, e.g. `border: 2px dashed #ff0000;`

src/components/LinkItems/Section.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
:icon="icon"
55
:uniqueKey="groupId"
66
:collapsed="displayData.collapsed"
7-
:cols="displayData.cols"
7+
:cols="effectiveColsSpan"
88
:rows="displayData.rows"
99
:color="displayData.color"
1010
:customStyles="displayData.customStyles"
@@ -128,6 +128,7 @@ export default {
128128
widgets: Array,
129129
index: Number,
130130
isWide: Boolean,
131+
activeColCount: Number,
131132
},
132133
components: {
133134
Collapsable,
@@ -209,6 +210,11 @@ export default {
209210
}
210211
return styles;
211212
},
213+
effectiveColsSpan() {
214+
const { cols } = this.displayData;
215+
if (!cols) return cols;
216+
return Math.min(this.activeColCount, cols);
217+
},
212218
},
213219
methods: {
214220
/* Opens the iframe modal */

src/views/Home.vue

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
</router-link>
2020
</div>
2121
<!-- Main content, section for each group of items -->
22-
<div v-if="checkTheresData(sections) || isEditMode" :class="computedClass">
22+
<div v-if="checkTheresData(sections) || isEditMode" :class="computedClass"
23+
ref="sectionsContainer">
2324
<template v-for="(section, index) in filteredSections">
2425
<Section
2526
:key="index"
@@ -36,6 +37,7 @@
3637
@change-modal-visibility="updateModalVisibility"
3738
:isWide="!!singleSectionView || layoutOrientation === 'horizontal'"
3839
:class="(searchValue && section.filteredItems.length === 0) ? 'no-results' : ''"
40+
:activeColCount="activeColCount"
3941
/>
4042
</template>
4143
<!-- Show add new section button, in edit mode -->
@@ -83,6 +85,7 @@ export default {
8385
layout: '',
8486
itemSizeBound: '',
8587
addNewSectionOpen: false,
88+
activeColCount: 1,
8689
}),
8790
computed: {
8891
singleSectionView() {
@@ -172,12 +175,26 @@ export default {
172175
availibleThemes.Default = '#';
173176
return availibleThemes;
174177
},
178+
readActiveColCount() {
179+
const { sectionsContainer } = this.$refs;
180+
if (!sectionsContainer) return;
181+
const cs = getComputedStyle(sectionsContainer);
182+
const varVal = parseInt(cs.getPropertyValue('--col-count'), 10);
183+
if (!Number.isNaN(varVal) && varVal > 0) {
184+
this.activeColCount = varVal;
185+
}
186+
},
175187
},
176188
mounted() {
177189
this.initiateFontAwesome();
178190
this.initiateMaterialDesignIcons();
179191
this.layout = this.layoutOrientation;
180192
this.itemSizeBound = this.iconSize;
193+
this.readActiveColCount();
194+
window.addEventListener('resize', this.readActiveColCount);
195+
},
196+
beforeDestroy() {
197+
window.removeEventListener('resize', this.readActiveColCount);
181198
},
182199
};
183200
</script>

0 commit comments

Comments
 (0)