@@ -57,11 +57,7 @@ export function focusSiblingElement(direction = 1) {
|
||||
).filter((el) => {
|
||||
// Filter out elements that are not visible or have display: none
|
||||
const style = window.getComputedStyle(el);
|
||||
return (
|
||||
style.display !== "none" &&
|
||||
style.visibility !== "hidden" &&
|
||||
el.offsetParent !== null
|
||||
);
|
||||
return style.display !== "none" && style.visibility !== "hidden";
|
||||
});
|
||||
|
||||
const currentIndex = focusableElements.indexOf(current);
|
||||
|
||||
@@ -93,6 +93,7 @@ export function RowButton({
|
||||
return (
|
||||
<button
|
||||
{...props}
|
||||
type="button"
|
||||
className="py-2 bg-highlight hover:bg-highlight-hover active:bg-highlight-pressed cursor-pointer w-full flex gap-2 items-center justify-center text-sm text-txt-secondary"
|
||||
style={{ gridColumnEnd: -1, gridColumnStart: 1 }}
|
||||
>
|
||||
|
||||
@@ -39,8 +39,8 @@ export function EditableRow(props: Props) {
|
||||
[props.errors],
|
||||
);
|
||||
return (
|
||||
<EditableRowContext value={value}>
|
||||
<EditableRowContext.Provider value={value}>
|
||||
<Row>{props.children}</Row>
|
||||
</EditableRowContext>
|
||||
</EditableRowContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { EditableCell, useEditableCellRef } from "./EditableCell.tsx";
|
||||
import { type KeyboardEventHandler, useRef, useState } from "react";
|
||||
import { type KeyboardEventHandler, useEffect, useRef, useState } from "react";
|
||||
import { useEditableRowContext } from "./EditableRow.tsx";
|
||||
|
||||
type Props = {
|
||||
@@ -27,6 +27,11 @@ export function TextCell(props: Props) {
|
||||
setValue(inputValue);
|
||||
onUpdate(props.name, inputValue);
|
||||
};
|
||||
|
||||
// Keep the value in sync with the props.defaultValue if defaultValue changes
|
||||
useEffect(() => {
|
||||
setValue(props.defaultValue);
|
||||
}, [props.defaultValue]);
|
||||
return (
|
||||
<EditableCell
|
||||
name={props.name}
|
||||
|
||||
@@ -3,7 +3,7 @@ export function getKey<T>(item: T): string {
|
||||
item &&
|
||||
typeof item === "object" &&
|
||||
"id" in item &&
|
||||
typeof item.id === "string"
|
||||
(typeof item.id === "string" || typeof item.id === "number")
|
||||
) {
|
||||
return item.id.toString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user