-
Notifications
You must be signed in to change notification settings - Fork 7
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
Conversation
There was a problem hiding this 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; |
There was a problem hiding this comment.
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 = () => { |
There was a problem hiding this comment.
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 | ||
*/ |
There was a problem hiding this comment.
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}> |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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> | ||
); | ||
}; |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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)} /> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this 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" |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
* 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
* 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
Issue #: WAITP-1211: Entity Search
Changes:
Screenshots: