Makes input buttons gray out when disabled, instead of solely disabling the input part you get after clicking. (#87588)

## About The Pull Request

While fiddling with NTNRC netadmin mode, I noticed that while renaming
is blocked on `strong = TRUE` channels like `#cargobus`, it doesn't gray
out the button like for deleting the channel.
Instead, clicking it still opens the input menu!... But that part _is_
disabled, thus being just an uninteractable black bar.

So in this pr we just make input buttons' `onClick` not work if
`disabled`, and apply `Button--disabled` to itself if so.
## Why It's Good For The Game

Grayed out button is much better than uninteractable black bar,
especially when normal disabled buttons are _also_ grayed out.
## Changelog
🆑
fix: NTNRC "rename channel" button is now grayed out when unusable.
fix: Genetics console "create advanced injector" button is now grayed
out when unusable.
/🆑
This commit is contained in:
_0Steven
2024-11-01 00:29:57 +01:00
committed by GitHub
parent 9300ba1b07
commit df7e74afb9
2 changed files with 7 additions and 1 deletions
+1
View File
@@ -256,6 +256,7 @@ commit, while escape cancels.
- See inherited props: [Box](#box)
- `fluid`: fill available horizontal space
- `disabled: boolean` - Disables and greys out the button.
- `onCommit: (e, value) => void`: function that is called after the user
defocuses the input or presses enter
- `currentValue: string`: default string to display when the input is shown
+6 -1
View File
@@ -315,10 +315,15 @@ const ButtonInput = (props: InputProps) => {
className={classes([
'Button',
fluid && 'Button--fluid',
disabled && 'Button--disabled',
'Button--color--' + color,
])}
{...rest}
onClick={() => setInInput(true)}
onClick={() => {
if (!disabled) {
setInInput(true);
}
}}
>
{icon && <Icon name={icon} rotation={iconRotation} spin={iconSpin} />}
<div>{toDisplay}</div>