Skip to content

Commit 125ff2a

Browse files
committed
fix: update default values to avoid displaying placeholders in event data
1 parent 49a853d commit 125ff2a

File tree

3 files changed

+25
-16
lines changed

3 files changed

+25
-16
lines changed

src/components/Timeline.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ export function Timeline({ events }: TimelineProps) {
305305

306306
<div className="flex">
307307
{/* Row titles */}
308-
<div className="flex-shrink-0 w-32 pr-3">
308+
<div className="flex-shrink-0 w-40 pr-3">
309309
<div style={{ height: `${timelineHeight}px`, position: "relative" }}>
310310
{rowTitles.map((title, i) => (
311311
<div

src/hooks/useKeyboardEvents.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function useKeyboardEvents() {
1313
const [filters, setFilters] = useState<EventFilters>({
1414
keydown: true,
1515
keyup: true,
16-
keypress: true,
16+
keypress: false,
1717
input: true,
1818
beforeinput: true,
1919
compositionstart: true,

src/utils/eventHelpers.ts

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const formatModifiers = (event: KeyboardEventData): string => {
3737
if (event.shiftKey) modifiers.push("Shift");
3838
if (event.altKey) modifiers.push("Alt");
3939
if (event.metaKey) modifiers.push("Meta");
40-
return modifiers.join("+") || "";
40+
return modifiers.join("+") || "";
4141
};
4242

4343
export const formatLocation = (location: number): string => {
@@ -51,7 +51,7 @@ export const formatLocation = (location: number): string => {
5151
};
5252

5353
export const formatBoolean = (value: boolean): string => {
54-
return value ? "✓" : "";
54+
return value ? "✓" : "";
5555
};
5656

5757
export const formatTextareaValue = (value: string): string => {
@@ -104,25 +104,31 @@ export const COLUMN_CONFIGS: ColumnConfig[] = [
104104
key: "key",
105105
header: "Key",
106106
eventTypes: ["keydown", "keyup", "keypress"],
107-
accessor: (e) => (e as KeyboardEventData).key || "",
107+
accessor: (e) => (e as KeyboardEventData).key || "",
108108
},
109109
{
110110
key: "code",
111111
header: "Code",
112112
eventTypes: ["keydown", "keyup", "keypress"],
113-
accessor: (e) => (e as KeyboardEventData).code || "",
113+
accessor: (e) => (e as KeyboardEventData).code || "",
114114
},
115115
{
116116
key: "keyCode",
117117
header: "KeyCode",
118118
eventTypes: ["keydown", "keyup", "keypress"],
119-
accessor: (e) => (e as KeyboardEventData).keyCode ?? 0,
119+
accessor: (e) => {
120+
const keyCode = (e as KeyboardEventData).keyCode;
121+
return keyCode && keyCode !== 0 ? keyCode.toString() : "";
122+
},
120123
},
121124
{
122125
key: "charCode",
123126
header: "CharCode",
124127
eventTypes: ["keypress"],
125-
accessor: (e) => (e as KeyboardEventData).charCode ?? 0,
128+
accessor: (e) => {
129+
const charCode = (e as KeyboardEventData).charCode;
130+
return charCode && charCode !== 0 ? charCode.toString() : "";
131+
},
126132
},
127133
{
128134
key: "modifiers",
@@ -134,7 +140,10 @@ export const COLUMN_CONFIGS: ColumnConfig[] = [
134140
key: "location",
135141
header: "Location",
136142
eventTypes: ["keydown", "keyup", "keypress"],
137-
accessor: (e) => (e as KeyboardEventData).location ?? 0,
143+
accessor: (e) => {
144+
const location = (e as KeyboardEventData).location;
145+
return location !== undefined ? location : 0;
146+
},
138147
formatter: (value) => formatLocation(value as number),
139148
},
140149
{
@@ -145,15 +154,15 @@ export const COLUMN_CONFIGS: ColumnConfig[] = [
145154
formatter: (value) =>
146155
value !== null && typeof value === "number"
147156
? `${value.toFixed(2)}ms`
148-
: "",
157+
: "",
149158
},
150159

151160
// Input event columns
152161
{
153162
key: "inputType",
154163
header: "Input Type",
155164
eventTypes: ["input", "beforeinput"],
156-
accessor: (e) => (e as InputEventData).inputType || "",
165+
accessor: (e) => (e as InputEventData).inputType || "",
157166
},
158167
{
159168
key: "data",
@@ -167,11 +176,11 @@ export const COLUMN_CONFIGS: ColumnConfig[] = [
167176
],
168177
accessor: (e) => {
169178
if (e.eventType === "input" || e.eventType === "beforeinput") {
170-
return (e as InputEventData).data || "";
179+
return (e as InputEventData).data || "";
171180
}
172-
return (e as CompositionEventData).data || "";
181+
return (e as CompositionEventData).data || "";
173182
},
174-
formatter: (value) => (value === null ? "" : JSON.stringify(value)),
183+
formatter: (value) => (value === null ? "" : JSON.stringify(value)),
175184
},
176185
{
177186
key: "isComposing",
@@ -216,8 +225,8 @@ export const getCellValue = (
216225
if (column.formatter) {
217226
return column.formatter(value);
218227
}
219-
return String(value ?? "");
228+
return String(value ?? "");
220229
} catch {
221-
return "";
230+
return "";
222231
}
223232
};

0 commit comments

Comments
 (0)