Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Mirador Video
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
IIIF
Mirador
Mirador Video
Commits
131ff8f7
Unverified
Commit
131ff8f7
authored
4 years ago
by
Jack Reed
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #3355 from dbmdz/contentsearch-fixes
Fixes for Content Search panel
parents
8218a6b0
292c346c
Loading
Loading
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/components/SearchPanelControls.js
+17
-7
17 additions, 7 deletions
src/components/SearchPanelControls.js
with
17 additions
and
7 deletions
src/components/SearchPanelControls.js
+
17
−
7
View file @
131ff8f7
...
@@ -2,6 +2,7 @@ import React, { Component } from 'react';
...
@@ -2,6 +2,7 @@ import React, { Component } from 'react';
import
PropTypes
from
'
prop-types
'
;
import
PropTypes
from
'
prop-types
'
;
import
deburr
from
'
lodash/deburr
'
;
import
deburr
from
'
lodash/deburr
'
;
import
debounce
from
'
lodash/debounce
'
;
import
debounce
from
'
lodash/debounce
'
;
import
isObject
from
'
lodash/isObject
'
;
import
Autocomplete
from
'
@material-ui/lab/Autocomplete
'
;
import
Autocomplete
from
'
@material-ui/lab/Autocomplete
'
;
import
CircularProgress
from
'
@material-ui/core/CircularProgress
'
;
import
CircularProgress
from
'
@material-ui/core/CircularProgress
'
;
import
TextField
from
'
@material-ui/core/TextField
'
;
import
TextField
from
'
@material-ui/core/TextField
'
;
...
@@ -9,6 +10,10 @@ import SearchIcon from '@material-ui/icons/SearchSharp';
...
@@ -9,6 +10,10 @@ import SearchIcon from '@material-ui/icons/SearchSharp';
import
MiradorMenuButton
from
'
../containers/MiradorMenuButton
'
;
import
MiradorMenuButton
from
'
../containers/MiradorMenuButton
'
;
import
SearchPanelNavigation
from
'
../containers/SearchPanelNavigation
'
;
import
SearchPanelNavigation
from
'
../containers/SearchPanelNavigation
'
;
/** Sometimes an autocomplete match can be a simple string, other times an object
with a `match` property, this function abstracts that away */
const
getMatch
=
(
option
)
=>
(
isObject
(
option
)
?
option
.
match
:
option
);
/** */
/** */
export
class
SearchPanelControls
extends
Component
{
export
class
SearchPanelControls
extends
Component
{
/** */
/** */
...
@@ -25,8 +30,7 @@ export class SearchPanelControls extends Component {
...
@@ -25,8 +30,7 @@ export class SearchPanelControls extends Component {
}
}
/**
/**
* Set the component's local search state
* Update the query in the component state if the query has changed in the redux store
* to blank when the query has been cleared
*/
*/
componentDidUpdate
(
prevProps
)
{
componentDidUpdate
(
prevProps
)
{
const
{
query
}
=
this
.
props
;
const
{
query
}
=
this
.
props
;
...
@@ -41,6 +45,11 @@ export class SearchPanelControls extends Component {
...
@@ -41,6 +45,11 @@ export class SearchPanelControls extends Component {
/** */
/** */
handleChange
(
event
,
value
,
reason
)
{
handleChange
(
event
,
value
,
reason
)
{
// For some reason the value gets reset to an empty value from the
// useAutocomplete hook sometimes, we just ignore these cases
if
(
reason
===
'
reset
'
&&
!
value
)
{
return
;
}
this
.
setState
({
this
.
setState
({
search
:
value
,
search
:
value
,
suggestions
:
[],
suggestions
:
[],
...
@@ -93,8 +102,8 @@ export class SearchPanelControls extends Component {
...
@@ -93,8 +102,8 @@ export class SearchPanelControls extends Component {
/** */
/** */
selectItem
(
_event
,
selectedItem
,
_reason
)
{
selectItem
(
_event
,
selectedItem
,
_reason
)
{
if
(
selectedItem
&&
selectedItem
.
match
)
{
if
(
selectedItem
&&
getMatch
(
selectedItem
)
)
{
this
.
setState
({
search
:
selectedItem
.
match
},
this
.
submitSearch
);
this
.
setState
({
search
:
getMatch
(
selectedItem
)
},
this
.
submitSearch
);
}
}
}
}
...
@@ -113,14 +122,15 @@ export class SearchPanelControls extends Component {
...
@@ -113,14 +122,15 @@ export class SearchPanelControls extends Component {
id
=
{
id
}
id
=
{
id
}
inputValue
=
{
search
}
inputValue
=
{
search
}
options
=
{
suggestions
}
options
=
{
suggestions
}
getOptionLabel
=
{
option
=>
option
.
m
atch
}
getOptionLabel
=
{
getM
atch
}
getOptionSelected
=
{(
option
,
value
)
=>
(
getOptionSelected
=
{(
option
,
value
)
=>
(
deburr
(
option
.
match
.
trim
()).
toLowerCase
()
deburr
(
getMatch
(
option
)
.
trim
()).
toLowerCase
()
===
deburr
(
value
.
match
.
trim
()).
toLowerCase
()
===
deburr
(
getMatch
(
value
)
.
trim
()).
toLowerCase
()
)}
)}
noOptionsText
=
""
noOptionsText
=
""
onChange
=
{
this
.
selectItem
}
onChange
=
{
this
.
selectItem
}
onInputChange
=
{
this
.
handleChange
}
onInputChange
=
{
this
.
handleChange
}
freeSolo
renderInput
=
{
params
=>
(
renderInput
=
{
params
=>
(
<
TextField
<
TextField
{...
params
}
{...
params
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment