Merge pull request #11123 from Budibase/fix/row-height-setting

Fix grid block row height not working
This commit is contained in:
Andrew Kingston 2023-07-04 09:57:38 +01:00 committed by GitHub
commit 434585a92d
6 changed files with 20 additions and 16 deletions

View File

@ -5274,7 +5274,7 @@
{ {
"type": "select", "type": "select",
"label": "Row height", "label": "Row height",
"key": "initialRowHeight", "key": "fixedRowHeight",
"placeholder": "Default", "placeholder": "Default",
"options": [ "options": [
{ {

View File

@ -12,7 +12,7 @@
export let initialFilter = null export let initialFilter = null
export let initialSortColumn = null export let initialSortColumn = null
export let initialSortOrder = null export let initialSortOrder = null
export let initialRowHeight = null export let fixedRowHeight = null
export let columns = null export let columns = null
const component = getContext("component") const component = getContext("component")
@ -47,7 +47,7 @@
{initialFilter} {initialFilter}
{initialSortColumn} {initialSortColumn}
{initialSortOrder} {initialSortOrder}
{initialRowHeight} {fixedRowHeight}
{columnWhitelist} {columnWhitelist}
{schemaOverrides} {schemaOverrides}
showControls={false} showControls={false}

View File

@ -8,7 +8,8 @@
SmallRowHeight, SmallRowHeight,
} from "../lib/constants" } from "../lib/constants"
const { stickyColumn, columns, rowHeight, table } = getContext("grid") const { stickyColumn, columns, rowHeight, table, fixedRowHeight } =
getContext("grid")
// Some constants for column width options // Some constants for column width options
const smallColSize = 120 const smallColSize = 120
@ -86,6 +87,7 @@
<div class="options"> <div class="options">
{#each rowSizeOptions as option} {#each rowSizeOptions as option}
<ActionButton <ActionButton
disabled={$fixedRowHeight}
quiet quiet
selected={$rowHeight === option.size} selected={$rowHeight === option.size}
on:click={() => changeRowHeight(option.size)} on:click={() => changeRowHeight(option.size)}
@ -118,15 +120,15 @@
<style> <style>
.content { .content {
padding: 12px; padding: 12px;
display: flex;
flex-direction: column;
gap: 16px;
} }
.size { .size {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 8px; gap: 8px;
} }
.size:first-child {
margin-bottom: 16px;
}
.options { .options {
display: flex; display: flex;
align-items: center; align-items: center;

View File

@ -43,7 +43,7 @@
export let initialFilter = null export let initialFilter = null
export let initialSortColumn = null export let initialSortColumn = null
export let initialSortOrder = null export let initialSortOrder = null
export let initialRowHeight = null export let fixedRowHeight = null
export let notifySuccess = null export let notifySuccess = null
export let notifyError = null export let notifyError = null
@ -90,7 +90,7 @@
initialFilter, initialFilter,
initialSortColumn, initialSortColumn,
initialSortOrder, initialSortOrder,
initialRowHeight, fixedRowHeight,
notifySuccess, notifySuccess,
notifyError, notifyError,
}) })

View File

@ -10,7 +10,7 @@ export const createStores = context => {
const initialSortColumn = getProp("initialSortColumn") const initialSortColumn = getProp("initialSortColumn")
const initialSortOrder = getProp("initialSortOrder") const initialSortOrder = getProp("initialSortOrder")
const initialFilter = getProp("initialFilter") const initialFilter = getProp("initialFilter")
const initialRowHeight = getProp("initialRowHeight") const fixedRowHeight = getProp("fixedRowHeight")
const schemaOverrides = getProp("schemaOverrides") const schemaOverrides = getProp("schemaOverrides")
const columnWhitelist = getProp("columnWhitelist") const columnWhitelist = getProp("columnWhitelist")
const notifySuccess = getProp("notifySuccess") const notifySuccess = getProp("notifySuccess")
@ -22,7 +22,7 @@ export const createStores = context => {
initialSortColumn, initialSortColumn,
initialSortOrder, initialSortOrder,
initialFilter, initialFilter,
initialRowHeight, fixedRowHeight,
schemaOverrides, schemaOverrides,
columnWhitelist, columnWhitelist,
notifySuccess, notifySuccess,

View File

@ -14,7 +14,7 @@ export const createStores = context => {
const focusedCellAPI = writable(null) const focusedCellAPI = writable(null)
const selectedRows = writable({}) const selectedRows = writable({})
const hoveredRowId = writable(null) const hoveredRowId = writable(null)
const rowHeight = writable(props.initialRowHeight || DefaultRowHeight) const rowHeight = writable(props.fixedRowHeight || DefaultRowHeight)
const previousFocusedRowId = writable(null) const previousFocusedRowId = writable(null)
const gridFocused = writable(false) const gridFocused = writable(false)
const isDragging = writable(false) const isDragging = writable(false)
@ -134,7 +134,7 @@ export const initialise = context => {
hoveredRowId, hoveredRowId,
table, table,
rowHeight, rowHeight,
initialRowHeight, fixedRowHeight,
} = context } = context
// Ensure we clear invalid rows from state if they disappear // Ensure we clear invalid rows from state if they disappear
@ -187,13 +187,15 @@ export const initialise = context => {
} }
}) })
// Pull row height from table // Pull row height from table as long as we don't have a fixed height
table.subscribe($table => { table.subscribe($table => {
rowHeight.set($table?.rowHeight || DefaultRowHeight) if (!get(fixedRowHeight)) {
rowHeight.set($table?.rowHeight || DefaultRowHeight)
}
}) })
// Reset row height when initial row height prop changes // Reset row height when initial row height prop changes
initialRowHeight.subscribe(height => { fixedRowHeight.subscribe(height => {
if (height) { if (height) {
rowHeight.set(height) rowHeight.set(height)
} else { } else {