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

WAITP-1211: Entity Dropdown Menu #4672

Merged
merged 15 commits into from
Jun 25, 2023

Conversation

tcaiger
Copy link
Contributor

@tcaiger tcaiger commented Jun 23, 2023

Issue #: WAITP-1211: Entity Search

Changes:

  • Add entities fetch
  • Add recursive entity menu
  • Add placeholder search bar

Screenshots:

image

image

@tcaiger tcaiger changed the base branch from epic-frontend-rewrite to waitp-1212-breadcrumbs June 23, 2023 03:25
@tcaiger tcaiger changed the base branch from waitp-1212-breadcrumbs to epic-frontend-rewrite June 23, 2023 03:25
@tcaiger tcaiger changed the title WAITP-1211: Entity Search WAITP-1211: Entity Dropdown Menu Jun 25, 2023
Copy link
Contributor

@alexd-bes alexd-bes left a comment

Choose a reason for hiding this comment

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

Looks good! Just a few comments from me

}: {
projectCode: string;
children: EntityWithChildren[];
isLoading: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

Possibly we could add this as an interface above the component, to keep with our current pattern?

const [isExpanded, setIsExpanded] = useState(false);
const { data, isLoading } = useEntities(projectCode!, entity.code!, { enabled: isExpanded });

const onExpand = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is really pedantic, but I would maybe rename this to be toggleExpanded to make it more representative of its function

/*
Pre-populate the next layer of the menu with children that came from the previous layer of entity
data then replace them with the children from the API response when it arrives
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice comments, really helpful

<MenuLink to={link}>
{entity.name} {entity.type === 'facility' && <HospitalIcon />}
</MenuLink>
<IconButton onClick={onExpand} disabled={parentIsLoading || !nextChildren}>
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think of only having the button when there are nextChildren? From an accessibility perspective this would be preferred I think, so that there isn't a button announced to the user that doesn't do anything

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about this and player around with it a bit. The button is really helpful to keep the spacing from glitching when the Icon button appears. The button is semantically disabled which helps.

)}
</div>
);
};
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be worth adding aria attributes to the menu, with aria-expanded on the menu as true/false. Also adding an aria-label to the expand button to explain what the button does would be good too

import { ClickAwayListener } from '@material-ui/core';
import { SearchBar } from './SearchBar';
import { EntityMenu } from './EntityMenu';
import { useParams } from 'react-router-dom';
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the linter will probably complain that this import isn't above local imports

};

return (
<SearchInput value={value} onChange={onChangeInputValue} onFocus={() => onFocusChange(true)} />
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure, but would it be useful to have an onBlur event listener here too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I initially had the onBlur event closing the entity menu but then I realised that the menu kept closing whenever I clicked on it and realised the blur was the problem so I don't think we want the blur for that interaction. Is there any thing else that you think should happen when you blur?

@tcaiger tcaiger requested a review from alexd-bes June 25, 2023 22:31
Copy link
Contributor

@alexd-bes alexd-bes left a comment

Choose a reason for hiding this comment

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

Looks good. Had a quick question on the aria stuff, but pre-approving.

<IconButton
onClick={toggleExpanded}
disabled={parentIsLoading || !nextChildren}
aria-controls="entity-expand-button"
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, thank you! Can we just add an aria-label of something like toggle menu for .... ?

children={nextChildren}
projectCode={projectCode}
isLoading={isLoading}
aria-expanded={isExpanded}
Copy link
Contributor

Choose a reason for hiding this comment

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

Just checking - does this get carried down to the menu element?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah very good point. I have moved it to the List element and it's always true there since the menu list only shows when expanded.

@tcaiger tcaiger merged commit 4401d37 into epic-frontend-rewrite Jun 25, 2023
@tcaiger tcaiger deleted the waitp-1211-entity-dropdown branch June 25, 2023 22:44
tcaiger added a commit that referenced this pull request Jul 12, 2023
* add breadcrumbs component

* set up entity search

* recursive menu

* fix types

* styles

* remove breadcrumbs

* Update EntityMenu.tsx

* pre load entity data

* get menu for project entity

* fixes

* Update EntityMenu.tsx
tcaiger added a commit that referenced this pull request Jul 12, 2023
* add breadcrumbs component

* set up entity search

* recursive menu

* fix types

* styles

* remove breadcrumbs

* Update EntityMenu.tsx

* pre load entity data

* get menu for project entity

* fixes

* Update EntityMenu.tsx
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