Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
4c73a88b
Unverified
Commit
4c73a88b
authored
1 year ago
by
Oisin Coveney
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Make sure filter button only appears when search bar is open (#33077)
parent
88451885
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/src/metabase/nav/components/SearchBar.tsx
+13
-10
13 additions, 10 deletions
frontend/src/metabase/nav/components/SearchBar.tsx
frontend/src/metabase/nav/components/SearchBar.unit.spec.tsx
+29
-0
29 additions, 0 deletions
frontend/src/metabase/nav/components/SearchBar.unit.spec.tsx
with
42 additions
and
10 deletions
frontend/src/metabase/nav/components/SearchBar.tsx
+
13
−
10
View file @
4c73a88b
...
...
@@ -194,16 +194,19 @@ function SearchBarView({ location, onSearchActive, onSearchInactive }: Props) {
onKeyPress
=
{
handleInputKeyPress
}
ref
=
{
searchInput
}
/>
<
SearchFunnelButton
icon
=
"filter"
data-is-filtered
=
{
isFiltered
}
data-testid
=
"search-bar-filter-button"
isFiltered
=
{
isFiltered
}
onClick
=
{
e
=>
{
e
.
stopPropagation
();
setIsFilterModalOpen
(
true
);
}
}
/>
{
(
!
isSmallScreen
()
||
isActive
)
&&
(
<
SearchFunnelButton
icon
=
"filter"
data-is-filtered
=
{
isFiltered
}
data-testid
=
"search-bar-filter-button"
isFiltered
=
{
isFiltered
}
onClick
=
{
e
=>
{
e
.
stopPropagation
();
setIsFilterModalOpen
(
true
);
}
}
/>
)
}
{
isSmallScreen
()
&&
isActive
&&
(
<
CloseSearchButton
onClick
=
{
handleClickOnClose
}
>
<
Icon
name
=
"close"
/>
...
...
This diff is collapsed.
Click to expand it.
frontend/src/metabase/nav/components/SearchBar.unit.spec.tsx
+
29
−
0
View file @
4c73a88b
...
...
@@ -17,6 +17,7 @@ import {
import
{
CollectionItem
,
RecentItem
}
from
"
metabase-types/api
"
;
import
SearchBar
from
"
metabase/nav/components/SearchBar
"
;
import
{
checkNotNull
}
from
"
metabase/core/utils/types
"
;
import
*
as
domUtils
from
"
metabase/lib/dom
"
;
const
TEST_SEARCH_RESULTS
:
CollectionItem
[]
=
[
"
Card ABC
"
,
...
...
@@ -97,6 +98,34 @@ describe("SearchBar", () => {
});
});
describe
(
"
rendering filter button with screen size
"
,
()
=>
{
it
(
"
should not render filter button on small screens
"
,
()
=>
{
const
isSmallScreenMock
=
jest
.
spyOn
(
domUtils
,
"
isSmallScreen
"
);
isSmallScreenMock
.
mockReturnValue
(
true
);
setup
();
expect
(
screen
.
queryByTestId
(
"
search-bar-filter-button
"
),
).
not
.
toBeInTheDocument
();
isSmallScreenMock
.
mockRestore
();
});
it
(
"
should render filter button on large screens
"
,
()
=>
{
const
isSmallScreenMock
=
jest
.
spyOn
(
domUtils
,
"
isSmallScreen
"
);
isSmallScreenMock
.
mockReturnValue
(
false
);
setup
();
expect
(
screen
.
getByTestId
(
"
search-bar-filter-button
"
),
).
toBeInTheDocument
();
isSmallScreenMock
.
mockRestore
();
});
});
describe
(
"
focusing on search bar
"
,
()
=>
{
it
(
"
should render `Recent Searches` list when clicking the search bar
"
,
async
()
=>
{
setup
();
...
...
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