mirror of
https://github.com/flarum/framework.git
synced 2025-03-09 03:35:41 +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();
|
const items = new ItemList();
|
||||||
|
|
||||||
if (this.isHidden()) {
|
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;
|
return items;
|
||||||
|
@ -102,11 +102,15 @@ export default class Forum extends Application {
|
|||||||
super.setupRoutes();
|
super.setupRoutes();
|
||||||
|
|
||||||
this.route.discussion = (discussion: Discussion, near?: number): string => {
|
this.route.discussion = (discussion: Discussion, near?: number): string => {
|
||||||
const slug = discussion.slug();
|
const slug = discussion?.slug();
|
||||||
return this.route(near && near !== 1 ? 'discussion.near' : 'discussion', {
|
const hasNear = near && near !== 1;
|
||||||
|
const params = {
|
||||||
id: discussion.id() + (slug.trim() ? '-' + slug : ''),
|
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 Component from '../../common/Component';
|
||||||
import Button from '../../common/components/Button';
|
import Button from '../../common/components/Button';
|
||||||
|
@ -542,7 +542,7 @@ class PostStream<T extends PostStreamProps = PostStreamProps> extends Component<
|
|||||||
if ($item.length) {
|
if ($item.length) {
|
||||||
const itemTop = $item.offset().top - this.getMarginTop();
|
const itemTop = $item.offset().top - this.getMarginTop();
|
||||||
const itemBottom = $item.offset().top + $item.height();
|
const itemBottom = $item.offset().top + $item.height();
|
||||||
const scrollTop = $(document).scrollTop();
|
const scrollTop = $container.scrollTop();
|
||||||
const scrollBottom = scrollTop + $(window).height();
|
const scrollBottom = scrollTop + $(window).height();
|
||||||
|
|
||||||
// If the item is already in the viewport, we may not need to scroll.
|
// If the item is already in the viewport, we may not need to scroll.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user