Skip to content

EES-5988 ckeditor insert modals focus on close #5755

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

Merged
merged 3 commits into from
Apr 4, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ const FormEditor = ({
};
}, [id]);

useEffect(() => {
if (!showFeaturedTablesModal && !showGlossaryModal) {
// setTimeout seems to be necessary otherwise it doesn't focus when
// successfully adding a link.
setTimeout(() => editorRef.current?.focus(), 0);
}
}, [showFeaturedTablesModal, showGlossaryModal]);

const handleLabelClick = useCallback(() => {
if (!editorRef.current) {
return;
Expand Down Expand Up @@ -354,7 +362,6 @@ const FormEditor = ({
onSubmit={item => {
featuredTablesPlugin.current?.addFeaturedTableLink(item);
toggleFeaturedTablesModal.off();
editorRef.current?.focus();
}}
/>
</Modal>
Expand All @@ -369,7 +376,6 @@ const FormEditor = ({
onSubmit={item => {
glossaryPlugin.current?.addGlossaryItem(item);
toggleGlossaryModal.off();
editorRef.current?.focus();
}}
/>
</Modal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,13 @@ export default function ChartBuilder({
<p>Are you sure you want to delete this chart?</p>
</ModalConfirm>
),
[initialChart, isDeleting, handleChartDelete, toggleDeleteModal],
[
initialChart,
isDeleting,
handleChartDelete,
toggleDeleteModal,
showDeleteModal,
],
);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Dictionary } from '@common/types';
import formatPretty from '@common/utils/number/formatPretty';
import { FeatureCollection } from 'geojson';
import Leaflet, { Layer, PathOptions } from 'leaflet';
import React, { useEffect, useRef, useState } from 'react';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { GeoJSON, useMap } from 'react-leaflet';

interface Props {
Expand Down Expand Up @@ -86,6 +86,8 @@ export default function MapGeoJSON({
}
}, [features]);

const resetZoom = useCallback(() => map.setZoom(5), [map]);

useEffect(() => {
if (!selectedFeature) {
resetZoom();
Expand All @@ -104,9 +106,7 @@ export default function MapGeoJSON({
// Centers the feature on the map
map.fitBounds(layer.getBounds());
}
}, [map, selectedFeature]);

const resetZoom = () => map.setZoom(5);
}, [map, selectedFeature, resetZoom]);

// We have to assign our `onEachFeature` callback to a ref
// as `onEachFeature` forms an internal closure which
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import styles from '@common/modules/find-statistics/components/KeyStatTile.module.scss';
import formatPretty from '@common/utils/number/formatPretty';
import React, { ReactNode } from 'react';

interface Props {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import PublicationReleaseHeadlinesSection from '@frontend/modules/find-statistic
import styles from '@frontend/modules/find-statistics/PublicationReleasePage.module.scss';
import classNames from 'classnames';
import orderBy from 'lodash/orderBy';
import { GetServerSideProps, NextPage, Redirect } from 'next';
import { GetServerSideProps, NextPage } from 'next';
import React from 'react';

interface Props {
Expand Down