1
0
Fork 0

[react] fix: Do not apply null layout. Closes #219

This commit is contained in:
joostdecock 2025-04-06 17:24:09 +02:00 committed by Joost De Cock
parent 25664d9b22
commit 96bce2ef7c

View file

@ -601,6 +601,9 @@ export const HeaderMenuLayoutViewIcons = (props) => {
const { pattern, update, state } = props
const [tweaks, setTweaks] = useState(0)
// Is the current custom layout an actual layout?
const layoutValid = typeof state.ui.layout === 'object'
useEffect(() => {
/*
* When the layout is reset, the UI won't update to changes
@ -617,7 +620,9 @@ export const HeaderMenuLayoutViewIcons = (props) => {
const applyLayout = () => {
setTweaks(-1)
update.settings('layout', state.ui.layout)
// Do not apply layout if it is not valid
if (layoutValid) update.settings('layout', state.ui.layout)
else update.notify({ msg: 'First create a custom layout', icon: 'tip' })
}
const resetLayout = () => {
setTweaks(-1)
@ -650,7 +655,7 @@ export const HeaderMenuLayoutViewIcons = (props) => {
<button
className="tw-daisy-btn tw-daisy-btn-ghost tw-daisy-btn-sm tw-px-1 disabled:tw-bg-transparent tw-text-secondary"
onClick={applyLayout}
disabled={tweaks === 0}
disabled={!layoutValid}
>
Apply Layout
</button>