Skip to content

Commit

Permalink
fix: board <select> update on board detach
Browse files Browse the repository at this point in the history
When the previously selected board is not detected, unset the `<select>`
option.

Closes #2222

Signed-off-by: Akos Kitta <[email protected]>
  • Loading branch information
Akos Kitta authored and kittaakos committed Jan 15, 2024
1 parent d01f956 commit 0ca1a31
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export const CertificateUploaderComponent = ({
const onItemSelect = React.useCallback(
(item: BoardOptionValue | null) => {
if (!item) {
setSelectedItem(null);
return;
}
const board = item.board;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { nls } from '@theia/core/lib/common';
import React from '@theia/core/shared/react';
import type {
BoardList,
BoardListItemWithBoard,
import {
boardListItemEquals,
type BoardList,
type BoardListItemWithBoard,
} from '../../../common/protocol/board-list';
import { ArduinoSelect } from '../../widgets/arduino-select';

Expand Down Expand Up @@ -75,7 +76,9 @@ export const SelectBoardComponent = ({
setSelectOptions(boardOptions);

if (selectedItem) {
selBoard = updatableBoards.indexOf(selectedItem);
selBoard = updatableBoards.findIndex((board) =>
boardListItemEquals(board, selectedItem)
);
}

selectOption(boardOptions[selBoard] || null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export const FirmwareUploaderComponent = ({
const onItemSelect = React.useCallback(
(item: BoardListItemWithBoard | null) => {
if (!item) {
setSelectedItem(null);
return;
}
const board = item.board;
Expand Down

0 comments on commit 0ca1a31

Please sign in to comment.