Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
12d2f2c0
Unverified
Commit
12d2f2c0
authored
Jun 11, 2020
by
kay delaney
Committed by
GitHub
Jun 11, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UI/Switch: Makes Switch ID generation more stable (#25542)
parent
79fea5df
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
packages/grafana-ui/src/components/Switch/Switch.tsx
+4
-4
No files found.
packages/grafana-ui/src/components/Switch/Switch.tsx
View file @
12d2f2c0
import
React
,
{
HTMLProps
}
from
'react'
;
import
React
,
{
HTMLProps
,
useRef
}
from
'react'
;
import
{
css
,
cx
}
from
'emotion'
;
import
uniqueId
from
'lodash/uniqueId'
;
import
{
GrafanaTheme
}
from
'@grafana/data'
;
...
...
@@ -79,7 +79,7 @@ export const Switch = React.forwardRef<HTMLInputElement, SwitchProps>(
({
value
,
checked
,
disabled
=
false
,
onChange
,
...
inputProps
},
ref
)
=>
{
const
theme
=
useTheme
();
const
styles
=
getSwitchStyles
(
theme
);
const
switchId
=
uniqueId
(
'switch-'
);
const
switchId
Ref
=
useRef
(
uniqueId
(
'switch-'
)
);
return
(
<
div
className=
{
cx
(
styles
.
switch
)
}
>
...
...
@@ -90,11 +90,11 @@ export const Switch = React.forwardRef<HTMLInputElement, SwitchProps>(
onChange=
{
event
=>
{
onChange
?.(
event
);
}
}
id=
{
switchId
}
id=
{
switchId
Ref
.
current
}
{
...
inputProps
}
ref=
{
ref
}
/>
<
label
htmlFor=
{
switchId
}
/>
<
label
htmlFor=
{
switchId
Ref
.
current
}
/>
</
div
>
);
}
...
...
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