Skip to content

Commit

Permalink
Extract a few changes from the Mithril 2 upgrade (#2262)
Browse files Browse the repository at this point in the history
* Fix closing the composer with ESC key

Regression from #2161.

* Remove obsolete method

Regression from #2162.

* Mark method as protected

* Fade in posts in post stream using CSS

This also avoids a double-fade from the JavaScript code, which was
probably introduced in #2160.

* Fix fadeIn for post stream items

Co-authored-by: Alexander Skvortsov <sasha.skvortsov109@gmail.com>
  • Loading branch information
franzliedke and askvortsov1 committed Sep 6, 2020
1 parent 5784199 commit 67c0ddc
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
2 changes: 0 additions & 2 deletions js/src/common/components/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ export default class Modal extends Component {
this.$('form').find('input, select, textarea').first().focus().select();
}

onhide() {}

/**
* Hide the modal.
*/
Expand Down
2 changes: 1 addition & 1 deletion js/src/forum/components/Composer.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default class Composer extends Component {
});

// When the escape key is pressed on any inputs, close the composer.
this.$().on('keydown', ':input', 'esc', () => this.close());
this.$().on('keydown', ':input', 'esc', () => this.state.close());

this.handlers = {};

Expand Down
6 changes: 0 additions & 6 deletions js/src/forum/components/PostStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ export default class PostStream extends Component {
}

view() {
function fadeIn(element, isInitialized, context) {
if (!context.fadedIn) $(element).hide().fadeIn();
context.fadedIn = true;
}

let lastTime;

const viewingEnd = this.stream.viewingEnd();
Expand All @@ -47,7 +42,6 @@ export default class PostStream extends Component {
content = PostComponent ? PostComponent.component({ post }) : '';

attrs.key = 'post' + post.id();
attrs.config = fadeIn;
attrs['data-time'] = time.toISOString();
attrs['data-number'] = post.number();
attrs['data-id'] = post.id();
Expand Down
2 changes: 1 addition & 1 deletion js/src/forum/components/SignUpModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export default class SignUpModal extends Modal {
* Get the data that should be submitted in the sign-up request.
*
* @return {Object}
* @public
* @protected
*/
submitData() {
const data = {
Expand Down
11 changes: 11 additions & 0 deletions less/forum/PostStream.less
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,18 @@
margin-top: 10px;
}
}

@-webkit-keyframes fadeIn {
0% {opacity: 0}
100% {opacity: 1}
}
@keyframes fadeIn {
0% {opacity: 0}
100% {opacity: 1}
}
.PostStream-item {
.animation(fadeIn 0.6s ease-in-out);

&:not(:last-child) {
border-bottom: 1px solid @control-bg;

Expand Down

0 comments on commit 67c0ddc

Please sign in to comment.