Skip to content
Open
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
16 changes: 16 additions & 0 deletions cypress/e2e/movie-details.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,20 @@ describe('Movie Details', () => {
'Minions: The Rise of Gru (2022)'
);
});

it('does not reopen the manager panel after closing and going back', () => {
cy.loginAsAdmin();

cy.visit('/movie/438148');
cy.visit('/movie/438148?manage=1');

cy.get('button[aria-label="Close panel"]').should('be.visible').click();
cy.location('search').should('eq', '');
cy.get('button[aria-label="Close panel"]').should('not.exist');

cy.go('back');

cy.location('search').should('eq', '');
cy.get('button[aria-label="Close panel"]').should('not.exist');
});
});
16 changes: 10 additions & 6 deletions src/components/MovieDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ const MovieDetails = ({ movie }: MovieDetailsProps) => {
const router = useRouter();
const intl = useIntl();
const { locale } = useLocale();
const [showManager, setShowManager] = useState(
router.query.manage == '1' ? true : false
);
const [showManager, setShowManager] = useState(false);
const minStudios = 3;
const [showMoreStudios, setShowMoreStudios] = useState(false);
const [showIssueModal, setShowIssueModal] = useState(false);
Expand Down Expand Up @@ -158,8 +156,14 @@ const MovieDetails = ({ movie }: MovieDetailsProps) => {
);

useEffect(() => {
setShowManager(router.query.manage == '1' ? true : false);
}, [router.query.manage]);
if (router.query.manage === '1') {
setShowManager(true);
router.replace({
pathname: router.pathname,
query: { movieId: router.query.movieId },
});
}
}, [router, router.query.manage]);

const closeBlocklistModal = useCallback(
() => setShowBlocklistModal(false),
Expand Down Expand Up @@ -469,7 +473,7 @@ const MovieDetails = ({ movie }: MovieDetailsProps) => {
mediaType="movie"
onClose={() => {
setShowManager(false);
router.push({
router.replace({
pathname: router.pathname,
query: { movieId: router.query.movieId },
});
Expand Down
14 changes: 10 additions & 4 deletions src/components/TvDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const TvDetails = ({ tv }: TvDetailsProps) => {
const intl = useIntl();
const { locale } = useLocale();
const [showRequestModal, setShowRequestModal] = useState(false);
const [showManager, setShowManager] = useState(router.query.manage == '1');
const [showManager, setShowManager] = useState(false);
const [showIssueModal, setShowIssueModal] = useState(false);
const [isUpdating, setIsUpdating] = useState<boolean>(false);
const [toggleWatchlist, setToggleWatchlist] = useState<boolean>(
Expand Down Expand Up @@ -154,8 +154,14 @@ const TvDetails = ({ tv }: TvDetailsProps) => {
);

useEffect(() => {
setShowManager(router.query.manage == '1');
}, [router.query.manage]);
if (router.query.manage === '1') {
setShowManager(true);
router.replace({
pathname: router.pathname,
query: { tvId: router.query.tvId },
});
}
}, [router, router.query.manage]);

const closeBlocklistModal = useCallback(
() => setShowBlocklistModal(false),
Expand Down Expand Up @@ -519,7 +525,7 @@ const TvDetails = ({ tv }: TvDetailsProps) => {
mediaType="tv"
onClose={() => {
setShowManager(false);
router.push({
router.replace({
pathname: router.pathname,
query: { tvId: router.query.tvId },
});
Expand Down
Loading