Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StaticElement from schema with content as function ignores tag field #229

Closed
thely opened this issue Apr 23, 2024 · 3 comments
Closed

StaticElement from schema with content as function ignores tag field #229

thely opened this issue Apr 23, 2024 · 3 comments

Comments

@thely
Copy link

thely commented Apr 23, 2024

Environment

Vite 5.1.5, Vue 3.4.21

Reproduction

https://stackblitz.com/edit/github-or77kl?file=src%2FApp.vue

Describe the bug

If you use StaticElement as a schema but try to set the content as a function, the tag field is then ignored, and no tag is applied.

<script setup>
import { reactive } from 'vue';
const schema = reactive({
  header: {
    type: 'static',
    tag: 'h2',
    content: ($el) => {
      return 'Hello World';
    },
  },
  hello_world: {
    type: 'text',
    label: 'Hello',
    placeholder: 'World',
  },
});
</script>

<template>
  <div class="max-w-[500px] mx-auto mt-10">
    <Vueform :schema="schema"> </Vueform>
  </div>
</template>

<style></style>

Additional context

No response

Logs

No response

@adamberecz
Copy link
Collaborator

It does work for me:
https://stackblitz.com/edit/github-or77kl-v6dwf9?file=src%2FApp.vue

(Your reproduction seemed to have a syntax error - not sure if that's the reason why you posted)

@thely
Copy link
Author

thely commented Apr 26, 2024

Sorry, yes - while I did close out the reactive early on StackBlitz, in your link, the StaticElement is still not being enclosed in an h2. This seems to happen only when the StaticElement's content is a function rather than a static value. For example, if I change it to the below code, the tag field works again.

header: {
  type: 'static',
  tag: 'h2',
  content: 'Hello World'
}

@adamberecz
Copy link
Collaborator

Should be now fixed in 1.9.7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants