Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor bug fix #39

Merged
merged 4 commits into from
Aug 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/helpers/jsonld_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
60 changes: 18 additions & 42 deletions app/javascript/flavours/glitch/packs/admin.js
Original file line number Diff line number Diff line change
@@ -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((
<AdminComponent locale={locale}>
<Component {...componentProps} />
</AdminComponent>
), 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((
<AdminComponent locale={locale}>
<Component {...componentProps} />
</AdminComponent>
), 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);

});
});
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class EmojiPickerMenu extends React.PureComponent {

state = {
modifierOpen: false,
placement: null,
readyToFocus: false,
};

handleDocumentClick = e => {
Expand All @@ -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 () {
Expand Down Expand Up @@ -281,7 +291,7 @@ class EmojiPickerMenu extends React.PureComponent {
showSkinTones={false}
backgroundImageFn={backgroundImageFn}
notFound={notFoundFn}
autoFocus
autoFocus={this.state.readyToFocus}
emojiTooltip
/>

Expand Down Expand Up @@ -314,6 +324,7 @@ class EmojiPickerDropdown extends React.PureComponent {
state = {
active: false,
loading: false,
placement: null,
};

setRef = (c) => {
Expand Down
8 changes: 1 addition & 7 deletions app/javascript/packs/public.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions app/javascript/styles/mastodon/admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,10 @@ $content-width: 840px;

& > ul {
display: none;

&.visible {
display: block;
}
}

ul a,
Expand Down