File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed
webview-ui/src/components/history Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,7 @@ const HistoryView = ({ onDone }: HistoryViewProps) => {
8383 < Button
8484 variant = { isSelectionMode ? "default" : "secondary" }
8585 onClick = { toggleSelectionMode }
86+ data-testid = "toggle-selection-mode-button"
8687 title = {
8788 isSelectionMode
8889 ? `${ t ( "history:exitSelectionMode" ) } `
@@ -217,8 +218,10 @@ const HistoryView = ({ onDone }: HistoryViewProps) => {
217218 "bg-vscode-list-activeSelectionBackground" :
218219 isSelectionMode && selectedTaskIds . includes ( item . id ) ,
219220 } ) }
220- onClick = { ( e ) => {
221- if ( ! isSelectionMode || ! ( e . target as HTMLElement ) . closest ( ".task-checkbox" ) ) {
221+ onClick = { ( ) => {
222+ if ( isSelectionMode ) {
223+ toggleTaskSelection ( item . id , ! selectedTaskIds . includes ( item . id ) )
224+ } else {
222225 vscode . postMessage ( { type : "showTaskWithId" , text : item . id } )
223226 }
224227 } } >
Original file line number Diff line number Diff line change @@ -148,6 +148,23 @@ describe("HistoryView", () => {
148148 } )
149149 } )
150150
151+ it ( "handles selection mode clicks" , async ( ) => {
152+ const onDone = jest . fn ( )
153+ render ( < HistoryView onDone = { onDone } /> )
154+
155+ // Go to selection mode
156+ fireEvent . click ( screen . getByTestId ( "toggle-selection-mode-button" ) )
157+
158+ const taskContainer = screen . getByTestId ( "task-item-1" )
159+
160+ // Click anywhere in the task item
161+ fireEvent . click ( taskContainer )
162+
163+ // Check the box instead of sending a message to open the task
164+ expect ( within ( taskContainer ) . getByRole ( "checkbox" ) ) . toBeChecked ( )
165+ expect ( vscode . postMessage ) . not . toHaveBeenCalled ( )
166+ } )
167+
151168 describe ( "task deletion" , ( ) => {
152169 it ( "shows confirmation dialog on regular click" , ( ) => {
153170 const onDone = jest . fn ( )
You can’t perform that action at this time.
0 commit comments