Skip to content

Commit

Permalink
feat(VConfirmEdit): pass props to actions
Browse files Browse the repository at this point in the history
closes #20704
  • Loading branch information
KaelWD committed Nov 20, 2024
1 parent 797cd88 commit 7aae81e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
15 changes: 10 additions & 5 deletions packages/vuetify/src/components/VConfirmEdit/VConfirmEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type VConfirmEditSlots<T> = {
save: () => void
cancel: () => void
isPristine: boolean
get actions (): VNode
get actions (): (props?: {}) => VNode
}
}

Expand Down Expand Up @@ -77,16 +77,16 @@ export const VConfirmEdit = genericComponent<new <T> (
emit('cancel')
}

let actionsUsed = false
useRender(() => {
const actions = (
function actions (actionsProps?: {}) {
return (
<>
<VBtn
disabled={ isPristine.value }
variant="text"
color={ props.color }
onClick={ cancel }
text={ t(props.cancelText) }
{ ...actionsProps }
/>

<VBtn
Expand All @@ -95,9 +95,14 @@ export const VConfirmEdit = genericComponent<new <T> (
color={ props.color }
onClick={ save }
text={ t(props.okText) }
{ ...actionsProps }
/>
</>
)
}

let actionsUsed = false
useRender(() => {
return (
<>
{
Expand All @@ -113,7 +118,7 @@ export const VConfirmEdit = genericComponent<new <T> (
})
}

{ !actionsUsed && actions }
{ !actionsUsed && actions() }
</>
)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe('VConfirmEdit', () => {
it('render actions', () => {
render(() => (
<VConfirmEdit>
{ ({ actions }) => actions }
{ ({ actions }) => actions() }
</VConfirmEdit>
))
expect(screen.getAllByCSS('button')).toHaveLength(2)
Expand Down
2 changes: 1 addition & 1 deletion packages/vuetify/src/labs/VDateInput/VDateInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export const VDateInput = genericComponent()({
onMousedown={ (e: MouseEvent) => e.preventDefault() }
>
{{
actions: !props.hideActions ? () => actions : undefined,
actions: !props.hideActions ? actions : undefined,
}}
</VDatePicker>
)
Expand Down

0 comments on commit 7aae81e

Please sign in to comment.