* feat: group configurations - index page * feat: [AXIMST-63] Index group configurations page * fix: resolve discussions * fix: resolve second round discussions * feat: group configurations - content group actions * feat: [AXIMST-75, AXIMST-69, AXIMST-81] Content group actions * fix: resolve conversations * feat: group configurations - sidebar * feat: [AXIMST-87] group-configuration page sidebar * refactor: [AXIMST-87] add changes after review * refactor: [AXIMST-87] add changes after review * refactor: [AXIMST-87] add changes ater review --------- Co-authored-by: Kyrylo Hudym-Levkovych <kyr.hudym@kyrs-MacBook-Pro.local> * fix: group configurations - the page reloads after the user saves changes * feat: group configurations - experiment groups * feat: [AXIMST-93, 99, 105] Group configuration - Experiment Groups * fix: [AXIMST-518, 537] Group configuration - resolve bugs * fix: review discussions * fix: revert classname case * fix: group configurations - resolve discussions fix: [AXIMST-714] icon is aligned with text (#210) * fix: add hook tests * fix: add thunk tests * fix: add slice tests * chore: group configurations - messages * fix: group configurations - remove delete in edit mode --------- Co-authored-by: Kyr <40792129+khudym@users.noreply.github.com> Co-authored-by: Kyrylo Hudym-Levkovych <kyr.hudym@kyrs-MacBook-Pro.local> Co-authored-by: monteri <lansevermore>
38 lines
954 B
JavaScript
38 lines
954 B
JavaScript
import { useEffect, useState } from 'react';
|
|
import { history } from '@edx/frontend-platform';
|
|
|
|
export const useScrollToHashElement = ({ isLoading }) => {
|
|
const [elementWithHash, setElementWithHash] = useState(null);
|
|
|
|
useEffect(() => {
|
|
const currentHash = window.location.hash.substring(1);
|
|
|
|
if (currentHash) {
|
|
const element = document.getElementById(currentHash);
|
|
if (element) {
|
|
element.scrollIntoView();
|
|
history.replace({ hash: '' });
|
|
}
|
|
setElementWithHash(currentHash);
|
|
}
|
|
}, [isLoading]);
|
|
|
|
return { elementWithHash };
|
|
};
|
|
|
|
export const useEscapeClick = ({ onEscape, dependency }) => {
|
|
useEffect(() => {
|
|
const handleEscapeClick = (event) => {
|
|
if (event.key === 'Escape') {
|
|
onEscape();
|
|
}
|
|
};
|
|
|
|
window.addEventListener('keydown', handleEscapeClick);
|
|
|
|
return () => {
|
|
window.removeEventListener('keydown', handleEscapeClick);
|
|
};
|
|
}, [dependency]);
|
|
};
|