Skip to content

Custom vue component does not override existing nova vue component #4143

Closed
outl1ne/nova-sortable
#121
@muhammadsaeedparacha

Description

@muhammadsaeedparacha
  • Laravel Version: 9.7
  • Nova Version: 3.2.7
  • PHP Version: 8.0.17
  • Database Driver & Version: Mysql 5.7.35
  • Operating System and Version: Mac OS Monterey 12.3.1
  • Browser type and version: Chrome latest
  • Reproduction Repository:

Description:

Custom Vue component does not override existing vue component. Such as modifying existing DefaultField.vue, which is a package that used to work in Nova 3

Detailed steps to reproduce the issue on a fresh Nova installation:

When I have a custom tool/asset
Which overrides an existing Vue Component: DefaultField
by declaring it again like

tool.js

import DefaultField from "./components/DefaultField";
Nova.booting((Vue) => {
    Vue.component("DefaultField", DefaultField);
});

Then my component does not override existing Nova Component.
If I delete vendor/laravel/nova/resources/js/components/DefaultField.vue and recompile and publish assets,
Then my custom component works. Which says there's a problem with vue component override. This used to work in Nova 3.

Fix:

laravel/nova/resources/js/app.js

liftoff() {
    this.log('We have lift off!')

    this.app.component('Link', Link)
    this.app.component('InertiaLink', Link)
    this.app.component('Head', Head)

    registerViews(this.app)
    registerFields(this.app)

    this.boot()
...
}

moving the registration of views and fields before booting fixes the issue.

Metadata

Metadata

Assignees

Labels

bugVerified bug by the Nova team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions