mirror of
https://github.com/flarum/framework.git
synced 2025-02-01 23:09:46 +08:00
forum: fix PostStream not scrolling to post number on load & potential issues with app.route.discussion
This commit is contained in:
parent
31cfe0f9df
commit
b9583943c5
2
js/dist/admin.js.map
vendored
2
js/dist/admin.js.map
vendored
File diff suppressed because one or more lines are too long
2
js/dist/forum.js
vendored
2
js/dist/forum.js
vendored
File diff suppressed because one or more lines are too long
2
js/dist/forum.js.map
vendored
2
js/dist/forum.js.map
vendored
File diff suppressed because one or more lines are too long
|
@ -78,7 +78,7 @@ export default class Discussion extends Model {
|
|||
const items = new ItemList();
|
||||
|
||||
if (this.isHidden()) {
|
||||
items.add('hidden', <Badge type="hidden" icon="fas fa-trash" label={app.translator.trans('core.lib.badge.hidden_tooltip')} />);
|
||||
items.add('hidden', <Badge type="hidden" icon="fas fa-trash" label={app.translator.transText('core.lib.badge.hidden_tooltip')} />);
|
||||
}
|
||||
|
||||
return items;
|
||||
|
|
|
@ -102,11 +102,15 @@ export default class Forum extends Application {
|
|||
super.setupRoutes();
|
||||
|
||||
this.route.discussion = (discussion: Discussion, near?: number): string => {
|
||||
const slug = discussion.slug();
|
||||
return this.route(near && near !== 1 ? 'discussion.near' : 'discussion', {
|
||||
const slug = discussion?.slug();
|
||||
const hasNear = near && near !== 1;
|
||||
const params = {
|
||||
id: discussion.id() + (slug.trim() ? '-' + slug : ''),
|
||||
near: near && near !== 1 ? near : undefined,
|
||||
});
|
||||
};
|
||||
|
||||
if (hasNear) params['near'] = near;
|
||||
|
||||
return this.route(near && near !== 1 ? 'discussion.near' : 'discussion', params);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {Vnode} from 'mithril';
|
||||
import { Vnode } from 'mithril';
|
||||
|
||||
import Component from '../../common/Component';
|
||||
import Button from '../../common/components/Button';
|
||||
|
|
|
@ -542,7 +542,7 @@ class PostStream<T extends PostStreamProps = PostStreamProps> extends Component<
|
|||
if ($item.length) {
|
||||
const itemTop = $item.offset().top - this.getMarginTop();
|
||||
const itemBottom = $item.offset().top + $item.height();
|
||||
const scrollTop = $(document).scrollTop();
|
||||
const scrollTop = $container.scrollTop();
|
||||
const scrollBottom = scrollTop + $(window).height();
|
||||
|
||||
// If the item is already in the viewport, we may not need to scroll.
|
||||
|
|
Loading…
Reference in New Issue
Block a user