Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Jump to anchor after submission #99

Closed
getflourish opened this issue Feb 16, 2021 · 7 comments
Closed

Jump to anchor after submission #99

getflourish opened this issue Feb 16, 2021 · 7 comments
Assignees
Labels
☑️ done Ready for beta, but not released yet
Milestone

Comments

@getflourish
Copy link

After a submission, it would be nice to jump to the comments section.

This could be done, e.g. by adjusting the form action in commentions-form.php

<form action="<?= $page->url() ?>#commentions" method="post" <?= option('sgkirby.commentions.hideforms') ? 'class="expandertarget"' : '' ?>>

But it would require an id on the commentions-list.

@getflourish
Copy link
Author

Ah, now see that the feedback is recommended to placed on the top of the page. Then the default behaviour makes sense. I actually placed the feedback with the form below the post. So maybe this issue can be seen as an option or just ignored. :)

@sebastiangreger
Copy link
Owner

Thanks for pointing out your use case!

I'll keep this in mind in combination with #96 ...display preferences after submission are quite obviously more diverse than what the current design enables and I consider it worth a try to accommodate them as flexibly as possible.

@sebastiangreger sebastiangreger self-assigned this Feb 16, 2021
@sebastiangreger sebastiangreger added the enhancement New feature or request label Feb 16, 2021
@sebastiangreger sebastiangreger added this to the 2.0 milestone Apr 29, 2021
@sebastiangreger sebastiangreger added ☑️ done Ready for beta, but not released yet and removed enhancement New feature or request labels Apr 29, 2021
@sebastiangreger
Copy link
Owner

This, too, is now possible in the Commentions 2.0 beta 1.

See the documentation at https://github.com/sebastiangreger/kirby3-commentions/tree/develop#frontend-helper ...you'd have to add an id attribute to the helper for the feedback section and a jump (or jump-success and jump-error) attribute to the form helper.

This is all beta still; feedback and bug reports are most welcome 🙂

@MaluNoPeleke
Copy link

I have played around and found this setup the best for my case:

    <?php
        commentions('feedback', ['class' => 'pt-[3.75rem] !mt-[-3.75rem]', 'id' => 'formfeedbacksuccess']);
        commentions('list', ['grouped' => true]);
        echo "<hr>";
        commentions('feedback', ['class' => 'pt-[3.75rem] !mt-[-3.75rem]', 'id' => 'formfeedbackerror']);
        commentions('form', ['class' => 'rounded-lg', 'collapse-webmentions' => false, 'jump-error' => 'formfeedbackerror', 'jump-success' => 'formfeedbacksuccess']);
    ?>

The only issue with this is that on a successful comment submit the feedback gets displayed twice. Is there a way to avoid that?

@sebastiangreger
Copy link
Owner

Hmm, having the feedback element twice on one page is a use case not currently considered. You're essentially after a "conditional" feedback element… I'll keep this in mind in future considerations.

Untested, but I imagine that this workaround should work:

if (get('thx')) {
    commentions('feedback', ['class' => 'pt-[3.75rem] !mt-[-3.75rem]', 'id' => 'formfeedbacksuccess']);
}
...
if (!get('thx')) {
    commentions('feedback', ['class' => 'pt-[3.75rem] !mt-[-3.75rem]', 'id' => 'formfeedbackerror']);
}
...

It makes use of the fact that a success message is always tied to ?thx=xyz present in the URL as the page is called.

@MaluNoPeleke
Copy link

Thanks, all your code snippets work as desired :)

@sebastiangreger
Copy link
Owner

@getflourish @MaluNoPeleke I hope you don't mind me pinging you here in a slightly off-topic manner, but I'd like to draw your attention to my update that I am no longer able to maintain the Commentions plugin in the future → details here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
☑️ done Ready for beta, but not released yet
Projects
None yet
Development

No branches or pull requests

3 participants