diff --git a/app/src/components/inventory/FieldCell.js b/app/src/components/inventory/FieldCell.js
index dd249df7..eececae7 100644
--- a/app/src/components/inventory/FieldCell.js
+++ b/app/src/components/inventory/FieldCell.js
@@ -13,7 +13,38 @@ import {ALL_UNITS, UNIT_GROUPS} from "./units";
// onUnitChange(unit) - quantity unit changed
// onEnter() - Enter pressed (submit row)
// inputRef - ref attached to the primary input
-export function FieldCell({field, value, unitValue, onChange, onUnitChange, onEnter, inputRef, listId}) {
+// autoFocus - on mount, focus the input and select its contents (for rapid inline edits)
+export function FieldCell({field, value, unitValue, onChange, onUnitChange, onEnter, inputRef, listId, autoFocus}) {
+ // Merge the parent's `inputRef` (used to focus the draft row's first field) with a local ref we use to
+ // focus + select this cell's contents when the user clicks it to edit.
+ const localRef = React.useRef(null);
+ const setRef = React.useCallback((node) => {
+ localRef.current = node;
+ if (typeof inputRef === 'function') {
+ inputRef(node);
+ } else if (inputRef) {
+ inputRef.current = node;
+ }
+ }, [inputRef]);
+
+ React.useEffect(() => {
+ if (!autoFocus) {
+ return;
+ }
+ const node = localRef.current;
+ // Semantic's Input exposes the DOM via `inputRef`; selecting its contents lets the user type over
+ // the value immediately. Other editors (e.g. Select) just take focus.
+ const dom = node && node.inputRef && node.inputRef.current;
+ if (dom) {
+ dom.focus();
+ if (dom.select) {
+ dom.select();
+ }
+ } else if (node && node.focus) {
+ node.focus();
+ }
+ }, [autoFocus]);
+
const handleKeyDown = (e) => {
if (e.key === 'Enter' && onEnter) {
e.preventDefault();
@@ -34,6 +65,7 @@ export function FieldCell({field, value, unitValue, onChange, onUnitChange, onEn
// Allow clearing.
return