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

Section extension: extending core sections doesn't work #6809

Open
tobimori opened this issue Nov 22, 2024 · 6 comments · May be fixed by #6915
Open

Section extension: extending core sections doesn't work #6809

tobimori opened this issue Nov 22, 2024 · 6 comments · May be fixed by #6915
Assignees
Milestone

Comments

@tobimori
Copy link
Contributor

tobimori commented Nov 22, 2024

Description

This is what I tried:

index.php

App::plugin('tobimori/test', ['sections' => ['submissions' => ['extends' => 'pages']]]);

Submissions.vue:

<script>
export default { extends: "k-pages-section" };
</script>

Result shows the empty pages section but clearly shows that no props are delivered (headline missing)
CleanShot 2024-11-22 at 16 12 52@2x

Let me know if you need anything else

Your setup

Kirby Version 4.4.1

@afbora
Copy link
Member

afbora commented Dec 6, 2024

Same issue was posted 1 year ago in forum https://forum.getkirby.com/t/how-to-extend-a-section/30517 but no replies.

@afbora
Copy link
Member

afbora commented Dec 6, 2024

@distantnative After long hours I found a clue for you. When I remove the load() method of the mixins, extending works. I think when extends is present, the load method of the mixins disables or overrides the ModelsSection::load() method.

I can take care the issue if solution is easy to implement. Currently I have no idea.

@distantnative
Copy link
Member

Ohhhhh, but great catch @afbora to find the source of this.

Maybe a workaround for now could be to not register the JS part as section but as component with k-THENAME-section. That should skip the mixing to be enforced which you wouldn't need when extending the modelssection anyway. Does that work?

For a real solution, maybe we need to consider not enforcing the section mixing but making it optional. Would be a breaking change for those plugins that then need to add it manually.

@afbora
Copy link
Member

afbora commented Dec 6, 2024

I couldn't figure out how to implement the workaround exactly. Also, doesn't k-models-section need to be defined to extend ModelsSection? As far as I can see, it isn't in https://github.com/getkirby/kirby/blob/4.5.0/panel/src/components/Sections/index.js

@distantnative
Copy link
Member

One would directly extend the models section of choice, e.g. in Tobi's case k-pages-section.

@distantnative distantnative changed the title Extending sections or using mixins in plugin sections doesn't work as expected Section extension: extending core sections doesn't work Jan 17, 2025
@distantnative
Copy link
Member

@tobimori Finally could test the workaround. For now, if you do

panel.plugin("test/test", {
	components: {
		"k-submissions-section": { extends: "k-pages-section" },
	},
});

instead of registering it via sections, it does work for me. Background is, that anything registered via sections gets another Vue mixin injected that overrides the load method (and thus no data, props...) is loaded from the backend. As you're extending the pages section, that already has its own load method defined, so you're absolutely fine without the mixing and can work around the bug this way.

@distantnative distantnative self-assigned this Jan 17, 2025
@distantnative distantnative linked a pull request Jan 17, 2025 that will close this issue
5 tasks
@distantnative distantnative linked a pull request Jan 17, 2025 that will close this issue
5 tasks
@distantnative distantnative added this to the 4.7.0 milestone Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants