diff --git a/src/Client/MainComponents/KeyboardShortcuts.fs b/src/Client/MainComponents/KeyboardShortcuts.fs index 1bd0e446..3ddd4a8c 100644 --- a/src/Client/MainComponents/KeyboardShortcuts.fs +++ b/src/Client/MainComponents/KeyboardShortcuts.fs @@ -16,6 +16,8 @@ let onKeydownEvent (dispatch: Messages.Msg -> unit) = MoveSelectedCell Key.Right |> Messages.SpreadsheetMsg |> dispatch | false, 40. -> // arrow down MoveSelectedCell Key.Down |> Messages.SpreadsheetMsg |> dispatch + | false, key when key <= 90 && key >= 65 -> + SetActiveCellFromSelected |> Messages.SpreadsheetMsg |> dispatch | false, _ -> () // Ctrl + c diff --git a/src/Client/States/Spreadsheet.fs b/src/Client/States/Spreadsheet.fs index 98d0d04a..0780acc1 100644 --- a/src/Client/States/Spreadsheet.fs +++ b/src/Client/States/Spreadsheet.fs @@ -101,6 +101,7 @@ type Msg = | UpdateSelectedCells of Set | MoveSelectedCell of Key | UpdateActiveCell of (U2 * ColumnType) option +| SetActiveCellFromSelected | RemoveTable of index:int | RenameTable of index:int * name:string | UpdateTableOrder of pre_index:int * new_index:int diff --git a/src/Client/Update/SpreadsheetUpdate.fs b/src/Client/Update/SpreadsheetUpdate.fs index ddfa56a2..02bca4b5 100644 --- a/src/Client/Update/SpreadsheetUpdate.fs +++ b/src/Client/Update/SpreadsheetUpdate.fs @@ -35,7 +35,8 @@ module Spreadsheet = /// let updateHistoryStorageMsg (msg: Spreadsheet.Msg) (state: Spreadsheet.Model, model: Messages.Model, cmd) = match msg with - | UpdateActiveView _ | UpdateHistoryPosition _ | Reset | UpdateSelectedCells _ | UpdateActiveCell _ | CopySelectedCell | CopyCell _ | MoveSelectedCell _ -> + | UpdateActiveView _ | UpdateHistoryPosition _ | Reset | UpdateSelectedCells _ + | UpdateActiveCell _ | CopySelectedCell | CopyCell _ | MoveSelectedCell _ | SetActiveCellFromSelected -> state.SaveToLocalStorage() // This will cache the most up to date table state to local storage. state, model, cmd | _ -> @@ -175,6 +176,15 @@ module Spreadsheet = let s = Set([nextIndex]) UpdateSelectedCells s |> SpreadsheetMsg |> Cmd.ofMsg state, model, cmd + | SetActiveCellFromSelected -> + let cmd = + if state.SelectedCells.IsEmpty then + Cmd.none + else + let min = state.SelectedCells.MinimumElement + let cmd = (Fable.Core.U2.Case2 min, ColumnType.Main) |> Some |> UpdateActiveCell |> SpreadsheetMsg + Cmd.ofMsg cmd + state, model, cmd | UpdateActiveCell next -> let nextState = { state with ActiveCell = next } nextState, model, Cmd.none