From c96f61d0fab4e935d2c882d353d51d8125090dd3 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sat, 12 Mar 2022 09:02:24 +0100 Subject: [PATCH 1/4] Fix nil error when trying to fetch key for signature verification (#17747) --- app/helpers/jsonld_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/jsonld_helper.rb b/app/helpers/jsonld_helper.rb index c6557817d0a481..ef16eef0864ae2 100644 --- a/app/helpers/jsonld_helper.rb +++ b/app/helpers/jsonld_helper.rb @@ -54,7 +54,7 @@ def supported_context?(json) end def unsupported_uri_scheme?(uri) - !uri.start_with?('http://', 'https://') + uri.nil? || !uri.start_with?('http://', 'https://') end def invalid_origin?(url) From 204d9708059aebb3943e0424f6fa8eee95f6a937 Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 16 Feb 2022 16:15:22 +0100 Subject: [PATCH 2/4] Fix toggling sidebar on mobile in admin pages --- app/javascript/flavours/glitch/packs/admin.js | 60 ++++++------------- 1 file changed, 18 insertions(+), 42 deletions(-) diff --git a/app/javascript/flavours/glitch/packs/admin.js b/app/javascript/flavours/glitch/packs/admin.js index b26df932cabc27..4c09ddb05c8024 100644 --- a/app/javascript/flavours/glitch/packs/admin.js +++ b/app/javascript/flavours/glitch/packs/admin.js @@ -1,48 +1,24 @@ import 'packs/public-path'; -import loadPolyfills from 'flavours/glitch/util/load_polyfills'; import ready from 'flavours/glitch/util/ready'; -import loadKeyboardExtensions from 'flavours/glitch/util/load_keyboard_extensions'; -function main() { - const { delegate } = require('@rails/ujs'); - - ready(() => { - const React = require('react'); - const ReactDOM = require('react-dom'); - - [].forEach.call(document.querySelectorAll('[data-admin-component]'), element => { - const componentName = element.getAttribute('data-admin-component'); - const { locale, ...componentProps } = JSON.parse(element.getAttribute('data-props')); - - import('flavours/glitch/containers/admin_component').then(({ default: AdminComponent }) => { - return import('flavours/glitch/components/admin/' + componentName).then(({ default: Component }) => { - ReactDOM.render(( - - - - ), element); - }); - }).catch(error => { - console.error(error); +ready(() => { + const React = require('react'); + const ReactDOM = require('react-dom'); + + [].forEach.call(document.querySelectorAll('[data-admin-component]'), element => { + const componentName = element.getAttribute('data-admin-component'); + const { locale, ...componentProps } = JSON.parse(element.getAttribute('data-props')); + + import('flavours/glitch/containers/admin_component').then(({ default: AdminComponent }) => { + return import('flavours/glitch/components/admin/' + componentName).then(({ default: Component }) => { + ReactDOM.render(( + + + + ), element); }); + }).catch(error => { + console.error(error); }); }); - - delegate(document, '.sidebar__toggle__icon', 'click', () => { - const target = document.querySelector('.sidebar ul'); - - if (target.style.display === 'block') { - target.style.display = 'none'; - } else { - target.style.display = 'block'; - } - }); -} - -loadPolyfills() - .then(main) - .then(loadKeyboardExtensions) - .catch(error => { - console.error(error); - - }); +}); From 3e6a2fa2265dd0412ba413a87c10b9a84cf18ec5 Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 16 Feb 2022 21:44:19 +0100 Subject: [PATCH 3/4] Fix edge case where settings/admin page sidebar would be incorrectly hidden (#17580) --- app/javascript/packs/public.js | 8 +------- app/javascript/styles/mastodon/admin.scss | 4 ++++ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/javascript/packs/public.js b/app/javascript/packs/public.js index 7ebe8b4d0c6d63..be467a8e25c6dd 100644 --- a/app/javascript/packs/public.js +++ b/app/javascript/packs/public.js @@ -151,13 +151,7 @@ function main() { }); delegate(document, '.sidebar__toggle__icon', 'click', () => { - const target = document.querySelector('.sidebar ul'); - - if (target.style.display === 'block') { - target.style.display = 'none'; - } else { - target.style.display = 'block'; - } + document.querySelector('.sidebar ul').classList.toggle('visible'); }); // Empty the honeypot fields in JS in case something like an extension diff --git a/app/javascript/styles/mastodon/admin.scss b/app/javascript/styles/mastodon/admin.scss index d28470747da25c..4e3d2aaa713411 100644 --- a/app/javascript/styles/mastodon/admin.scss +++ b/app/javascript/styles/mastodon/admin.scss @@ -322,6 +322,10 @@ $content-width: 840px; & > ul { display: none; + + &.visible { + display: block; + } } ul a, From 044e8fbe9c90aec249588ff06e395815a2c4990d Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 16 Feb 2022 21:44:47 +0100 Subject: [PATCH 4/4] Fix opening the emoji picker scrolling the single-column view to the top (#17579) Fixes #17577 --- .../compose/components/emoji_picker_dropdown.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.js b/app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.js index 4a87714e644804..f433e4de9faa6a 100644 --- a/app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.js +++ b/app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.js @@ -170,7 +170,7 @@ class EmojiPickerMenu extends React.PureComponent { state = { modifierOpen: false, - placement: null, + readyToFocus: false, }; handleDocumentClick = e => { @@ -182,6 +182,16 @@ class EmojiPickerMenu extends React.PureComponent { componentDidMount () { document.addEventListener('click', this.handleDocumentClick, false); document.addEventListener('touchend', this.handleDocumentClick, listenerOptions); + + // Because of https://github.com/react-bootstrap/react-bootstrap/issues/2614 we need + // to wait for a frame before focusing + requestAnimationFrame(() => { + this.setState({ readyToFocus: true }); + if (this.node) { + const element = this.node.querySelector('input[type="search"]'); + if (element) element.focus(); + } + }); } componentWillUnmount () { @@ -281,7 +291,7 @@ class EmojiPickerMenu extends React.PureComponent { showSkinTones={false} backgroundImageFn={backgroundImageFn} notFound={notFoundFn} - autoFocus + autoFocus={this.state.readyToFocus} emojiTooltip /> @@ -314,6 +324,7 @@ class EmojiPickerDropdown extends React.PureComponent { state = { active: false, loading: false, + placement: null, }; setRef = (c) => {