[Glitch] Manage focus on navigation
Port bcb8553e01 to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
1 parent
5893554a3a
commit
4cb1bf73c9
21 files changed
+254
-33
No files matched your search
@@ -7,6 +7,7 @@ import { multiply } from 'color-blend';
|
||||
import { createBrowserHistory } from 'history';
|
||||
|
||||
import { WithOptionalRouterPropTypes, withOptionalRouter } from 'flavours/glitch/utils/react_router';
|
||||
import { IGNORE_FOCUS_ON_OPEN } from '../reducers/modal';
|
||||
|
||||
class ModalRoot extends PureComponent {
|
||||
|
||||
@@ -22,7 +23,10 @@ class ModalRoot extends PureComponent {
|
||||
}),
|
||||
]),
|
||||
noEsc: PropTypes.bool,
|
||||
ignoreFocus: PropTypes.bool,
|
||||
ignoreFocus: PropTypes.oneOfType([
|
||||
PropTypes.bool,
|
||||
PropTypes.string, // 'on-open', see IGNORE_FOCUS_ON_OPEN
|
||||
]),
|
||||
...WithOptionalRouterPropTypes,
|
||||
};
|
||||
|
||||
@@ -123,7 +127,11 @@ class ModalRoot extends PureComponent {
|
||||
_ensureHistoryBuffer () {
|
||||
const { pathname, search, hash, state } = this.history.location;
|
||||
if (!state || state.mastodonModalKey !== this._modalHistoryKey) {
|
||||
this.history.push({ pathname, search, hash }, { ...state, mastodonModalKey: this._modalHistoryKey });
|
||||
this.history.push({ pathname, search, hash }, {
|
||||
...state,
|
||||
focusTarget: this.props.ignoreFocus !== IGNORE_FOCUS_ON_OPEN,
|
||||
mastodonModalKey: this._modalHistoryKey,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user