-
Notifications
You must be signed in to change notification settings - Fork 192
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
fix: remove search criteria selector and auto expand results #571
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ | |
|
||
*/ | ||
|
||
import React, { FC, useContext, useState } from 'react' | ||
import React, { FC, useContext, useEffect, useState } from 'react' | ||
import styled from 'styled-components' | ||
import { | ||
Accordion, | ||
|
@@ -48,7 +48,7 @@ interface MethodsProps { | |
|
||
const SideNavMethodsLayout: FC<MethodsProps> = ({ | ||
className, | ||
defaultOpen, | ||
defaultOpen = false, | ||
methods, | ||
tag, | ||
specKey, | ||
|
@@ -59,9 +59,7 @@ const SideNavMethodsLayout: FC<MethodsProps> = ({ | |
const match = useRouteMatch<{ methodTag: string }>( | ||
`/:specKey/methods/:methodTag/:methodName?` | ||
) | ||
const [isOpen, setIsOpen] = useState( | ||
match ? defaultOpen || match.params.methodTag === tag : defaultOpen | ||
) | ||
const [isOpen, setIsOpen] = useState(defaultOpen) | ||
const history = useHistory() | ||
|
||
const handleOpen = () => { | ||
|
@@ -70,6 +68,13 @@ const SideNavMethodsLayout: FC<MethodsProps> = ({ | |
if (_isOpen) history.push(`/${specKey}/methods/${tag}`) | ||
} | ||
|
||
useEffect(() => { | ||
const status = match | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. setIsOpen defaults to defaultOpen but you are modifying the value if the value of defaultOpen changes. Is defaultOpen a good name? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can find a better name for another PR |
||
? defaultOpen || match.params.methodTag === tag | ||
: defaultOpen | ||
setIsOpen(status) | ||
}, [defaultOpen]) | ||
|
||
return ( | ||
<Accordion | ||
defaultOpen={defaultOpen} | ||
|
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 don't understand the comment. Perhaps a little more clarity on why. Possibly because entering characters being entered one by results in search being triggered for each character?
Something like
Using ... triggers search multiple times. Use of paste avoids this