Skip to content

Commit

Permalink
Non-reactive configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
MisRob committed Sep 20, 2024
1 parent 4710d9f commit d4b02df
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 8 additions & 0 deletions docs/pages/kcardgrid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
{ text: 'Card height, content tolerance and alignment', href: '#card-height-and-alignment' },
{ text: 'Fine-tuning responsiveness', href: '#fine-tuning-responsiveness' },
{ text: 'Loading state (TBD)', href: '#loading-state' },
{ text: 'Non-reactive configuration', href: '#non-reactive-configuration' },
]"
/>

Expand Down Expand Up @@ -568,6 +569,13 @@
</h3>

<p>When cards are loading, <code>KCardGrid</code> displays skeleton cards...(TBD)</p>

<h3>
Non-reactive configuration
<DocsAnchorTarget anchor="#non-reactive-configuration" />
</h3>

<p>Note that <code>layout</code>, <code>layoutOverride</code>, and <code>skeletonsOverride</code> props do not provide reactive behavior so grids won't be updated when they change. Reactivity would add performance cost, and since grids are configured once, it's unnecessary.</p>
</DocsPageSection>

<DocsPageSection title="Related" anchor="#related">
Expand Down
7 changes: 3 additions & 4 deletions lib/cards/useResponsiveGridLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,12 @@ export default function useResponsiveGridLayout(props) {
return finalBreakpointConfig;
}

// Watch props too to make `layout` and `layoutOverride` reactive
watch(
[windowBreakpoint, props],
([newBreakpoint]) => {
windowBreakpoint,
newBreakpoint => {
currentBreakpointConfig.value = getLayoutConfigForBreakpoint(props, newBreakpoint);
},
{ immediate: true, deep: true }
{ immediate: true }
);

return { currentBreakpointConfig };
Expand Down

0 comments on commit d4b02df

Please sign in to comment.