Skip to content

docs(alert): flat avatar.* keys under props: render no avatar #575

Description

@IgorShevchik

docs/content/docs/2.components/alert.md:81-83 passes the avatar as flat dotted
keys in the ::component-code frontmatter:

props:
  avatar.src: '/b24ui/avatar/employee.png'
  avatar.size: ...
  avatar.loading: ...

docs/app/components/content/ComponentCode.vue builds componentProps straight
from the literal entries:

const componentProps = reactive({
  ...Object.fromEntries(Object.entries(props.props || {}).map(([key, value]) => {
    // ...
    return [key, cast ? castMap[cast]!.get(value) : value]
  }))
})

Nothing expands a dotted key into a nested object, so the component receives a
prop literally named avatar.src and never an avatar object. The avatar
branch is gated on props.avatar, so the example renders no avatar at all,
and avatar.src="…" leaks onto the root element as an attribute. The generated
snippet the reader copies is not valid Vue either.

The correct form, used elsewhere in the same docs tree, is nested:

props:
  avatar:
    src: '/b24ui/avatar/employee.png'

Note the ignore: / hide: lists are a different thing — they take dotted
paths on purpose (mapKeys in the same file builds them), so - avatar.src
under ignore: is correct and must stay as it is. Only keys under props: are
affected.

Scope

grep -rn "^\s*avatar\.[a-zA-Z]*:" docs/content/ finds this in alert.md only —
the other occurrences were in user.md and were fixed alongside the User
color work. Worth re-running the grep at fix time rather than trusting this
line, and worth widening it: any prop whose value is an object can have been
written the same way, not just avatar.

Not verified

The claim that the example renders no avatar comes from reading
ComponentCode.vue and the component's v-if, not from opening the docs site.
Confirm in the browser before and after.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions