Dropdown selected element highlighting (#75255)

## About The Pull Request
This PR makes selected elements in Dropdowns to be highlighted.
Without this:

![image](https://user-images.githubusercontent.com/5000549/236760396-5eb71a23-7b3d-4a9e-98d4-6bd4dc5fe1c7.png)
With this:

![image](https://user-images.githubusercontent.com/5000549/236758675-b2ab90a7-0482-492e-b911-9e59f827f6b8.png)
## Why It's Good For The Game
It's convenient to have this kind of selection indication, especially in
long lists.
## Changelog
🆑
qol: Made selected elements highlighted in TGUI Dropdowns
/🆑
This commit is contained in:
Serge K Lebedev
2023-05-11 16:06:56 +12:00
committed by GitHub
parent 360ad68c1c
commit 84ba2dc937
2 changed files with 15 additions and 11 deletions
+10 -11
View File
@@ -69,20 +69,16 @@ export class Dropdown extends Component<DropdownProps, DropdownState> {
Dropdown.currentOpenMenu?.getBoundingClientRect() ?? NULL_RECT,
};
menuContents: any;
handleClick: any;
state: DropdownState = {
open: false,
selected: this.props.selected,
};
constructor() {
super();
this.handleClick = () => {
if (this.state.open) {
this.setOpen(false);
}
};
}
handleClick = () => {
if (this.state.open) {
this.setOpen(false);
}
};
getDOMNode() {
return findDOMfromVNode(this.$LI, true);
@@ -170,7 +166,10 @@ export class Dropdown extends Component<DropdownProps, DropdownState> {
return (
<div
key={value}
className="Dropdown__menuentry"
className={classes([
'Dropdown__menuentry',
this.state.selected === value && 'selected',
])}
onClick={() => {
this.setSelected(value);
}}>
@@ -51,6 +51,11 @@
line-height: base.em(17px);
transition: background-color 100ms ease-out;
&.selected {
background-color: rgba(255, 255, 255, 0.5) !important;
transition: background-color 0ms;
}
&:hover {
background-color: rgba(255, 255, 255, 0.2);
transition: background-color 0ms;