Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
54e7744e
Commit
54e7744e
authored
Sep 19, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mitigate flickering
parent
bf49b2b5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
2 deletions
+10
-2
RoutedTabs.tsx
ui/shared/RoutedTabs/RoutedTabs.tsx
+7
-1
useAdaptiveTabs.tsx
ui/shared/RoutedTabs/useAdaptiveTabs.tsx
+3
-1
No files found.
ui/shared/RoutedTabs/RoutedTabs.tsx
View file @
54e7744e
...
@@ -67,7 +67,13 @@ const RoutedTabs = ({ tabs, defaultActiveTab }: Props) => {
...
@@ -67,7 +67,13 @@ const RoutedTabs = ({ tabs, defaultActiveTab }: Props) => {
activeTab=
{
tabs
[
activeTab
]
}
activeTab=
{
tabs
[
activeTab
]
}
tabsCut=
{
tabsCut
}
tabsCut=
{
tabsCut
}
isActive=
{
activeTab
>=
tabsCut
}
isActive=
{
activeTab
>=
tabsCut
}
styles=
{
tabsCut
<
tabs
.
length
?
{}
:
hiddenItemStyles
}
styles=
{
tabsCut
<
tabs
.
length
?
// initially our cut is 0 and we don't want to show the menu button too
// but we want to keep it in the tabs row so it won't collapse
// that's why we only change opacity but not the position itself
{
opacity
:
tabsCut
===
0
?
0
:
1
}
:
hiddenItemStyles
}
onItemClick=
{
handleItemInMenuClick
}
onItemClick=
{
handleItemInMenuClick
}
buttonRef=
{
tabsRefs
[
index
]
}
buttonRef=
{
tabsRefs
[
index
]
}
/>
/>
...
...
ui/shared/RoutedTabs/useAdaptiveTabs.tsx
View file @
54e7744e
...
@@ -6,7 +6,9 @@ import type { RoutedTab } from './types';
...
@@ -6,7 +6,9 @@ import type { RoutedTab } from './types';
import
{
menuButton
}
from
'
./utils
'
;
import
{
menuButton
}
from
'
./utils
'
;
export
default
function
useAdaptiveTabs
(
tabs
:
Array
<
RoutedTab
>
)
{
export
default
function
useAdaptiveTabs
(
tabs
:
Array
<
RoutedTab
>
)
{
const
[
tabsCut
,
setTabsCut
]
=
React
.
useState
(
tabs
.
length
);
// to avoid flickering we set initial value to 0
// so there will be no displayed tabs initially
const
[
tabsCut
,
setTabsCut
]
=
React
.
useState
(
0
);
const
[
tabsRefs
,
setTabsRefs
]
=
React
.
useState
<
Array
<
React
.
RefObject
<
HTMLButtonElement
>>>
([]);
const
[
tabsRefs
,
setTabsRefs
]
=
React
.
useState
<
Array
<
React
.
RefObject
<
HTMLButtonElement
>>>
([]);
const
listRef
=
React
.
useRef
<
HTMLDivElement
>
(
null
);
const
listRef
=
React
.
useRef
<
HTMLDivElement
>
(
null
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment