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

EES-4510 release type modal on release page #4306

Merged
merged 1 commit into from
Sep 21, 2023
Merged

EES-4510 release type modal on release page #4306

merged 1 commit into from
Sep 21, 2023

Conversation

amyb-hiveit
Copy link
Collaborator

Moves the release type from a tag at the top to the summary list. Clicking it will open a modal containing information about the release type.

I've done a bit of tidying to reduce inconsistencies between the admin and public versions of the release pages:

  • added a BasicReleaseSummary component for use in both and removed the admin only one
  • combined both the ReleaseHelpAndSupportSection components into one

Also, I've made a change to the Modal component to make it simpler to have the content be scrollable and have a close button. This is used on the Glossary and Find Stats - Filters modals as well as the new one for release type.

releasetype-pr

Comment on lines 61 to 62
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
tabIndex={0}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than need the tabIndex, could we sort the scrolling out so that the entire window doesn't scroll when the modal is open?

There are various modal (or dialog) implementations that handle this in slightly different ways:

The main approach seems to be to overflow: hidden the body when the modal opens.

I'd suggest we go a little further and replace the underlying implementation with Radix's as it seems to be getting more support than react-modal. For example, this issue seems to suggest that it won't work with React 18, making itanother blocker for upgrading.

If we swap out the implementation, we shouldn't need to do any messing about with the scroll locking ourselves and we can also remove stuff like having to set process.env.APP_ROOT_ID.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tabIndex here is for the scrollable area inside the modal, not the modal itself (the screenshot is of how it works currently). If we made the whole modal scrollable (is that what you're suggesting?) I don't think it would work as well as the close button wouldn't be visible until you scroll to the bottom.
modal

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, we can keep the tabIndex if we want to always show the Close button. However, it's still be a good idea to lock the scrolling on the main window viewport as it's a bit weird to have two scrollbars.

I wonder if it'd be possible if we could scroll the modal content when scrolling outside the modal i.e. on the overlay. Not super necessary though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scrolling - I've actually changed my mind now after testing them out on a few more screen sizes and have changed it to scroll the whole modal instead of just the content section.

I've started switching over to Radix but it's going to be a lot of changes so I'll do that in a follow up PR instead of this one (https://dfedigital.atlassian.net/browse/EES-4567). That'll sort the scroll locking issue as well.

@@ -11,6 +12,8 @@ export interface ModalProps {
fullScreen?: boolean;
hideTitle?: boolean;
open?: boolean;
scrollableContent?: boolean;
showCloseButton?: boolean;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Would suggest simplifying this to showClose. This would be more consistent with ModalConfirm
  • Could add an optional cancelText prop (defaulting to 'Close')

@@ -1,8 +1,12 @@
import React from 'react';

const AdHocOfficialStatisticsSection = () => (
const AdHocStatisticsSection = ({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Could export default function this. Same for the other section components in this PR as well.
  • All the section components are in modules/find-statistics. A more appropriate place would be modules/release.

It actually seems like all the find-statistics module files could be moved over to the release module. Would suggest we do a quick follow up PR with this change to clean this up finally.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've moved these and will do a tidy up PR for the rest later.

onToggleReleaseTypeModal?: () => void;
}

export default function BasicReleaseSummary({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we could name this a bit better e.g. ReleaseSummaryList or ReleaseSummarySection.

It seems a bit weird to call it BasicReleaseSummary as there isn't a more complicated version of this component. It could also be a little confusing if we introduce a more trimmed ReleaseSummary type in the future too.

altText: string;
}

const nationalStatisticsLogo: ReleaseTypeIcon = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be just inlined into releaseTypesToIcons

altText: 'UK statistics authority quality mark',
};

const releaseTypesToIcons: Dictionary<ReleaseTypeIcon> = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A better type for this would be Partial<Record<ReleaseType, ReleaseTypeIcon>>

renderReleaseNotes: ReactNode;
renderStatusTags: ReactNode;
renderSubscribeLink: ReactNode;
onToggleReleaseTypeModal?: () => void;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onShowReleaseTypeModal might be better. onToggle implies the event should fire when the modal closes too.

</SummaryList>

<Modal
className="govuk-!-width-one-half"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this responds too great on smaller desktops / tablets:

image

It doesn't seem like we really need this at all personally.

Without the width:

image

With the width:

image

Comment on lines 16 to 22
export const releaseTypeComponents = {
NationalStatistics: NationalStatisticsSection,
OfficialStatistics: OfficialStatisticsSection,
ExperimentalStatistics: ExperimentalStatisticsSection,
AdHocStatistics: AdHocStatisticsSection,
ManagementInformation: ManagementInformationSection,
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't seem appropriate to put this in here. This is the services directory, so we shouldn't need to put React components in here.

These are also quite specific to the section components for the release pages, which doesn't make a lot of sense for a file that will be used more generally.

Would suggest we just create a dedicated ReleaseTypeSection component that takes a type prop and wraps these other sections. We might even want to just move all the other section components into the same file for simplicity (up to you).


.content {
margin-bottom: govuk-spacing(5);
max-height: 50vh;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to bump this up some more? Something like 70vh could be better.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been removed now.

@amyb-hiveit amyb-hiveit force-pushed the EES-4510 branch 2 times, most recently from 8b64936 to 873e534 Compare September 20, 2023 09:13
@amyb-hiveit amyb-hiveit requested a review from ntsim September 20, 2023 09:14

export interface ModalProps {
cancelText?: string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry my bad, but I actually meant closeText! Could move this next to the other close props too

import { ReleaseType } from '@common/services/types/releaseType';
import React from 'react';

export const releaseTypeComponents = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These don't need to be exported anymore

@amyb-hiveit amyb-hiveit merged commit 0c41fae into dev Sep 21, 2023
6 checks passed
@amyb-hiveit amyb-hiveit deleted the EES-4510 branch September 21, 2023 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants