Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
shrunyan committed Mar 25, 2024
2 parents d87c313 + b00a280 commit c959f6c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,8 @@ export const ItemEditHeaderActions = ({
{itemState === ITEM_STATES.draft ||
itemState === ITEM_STATES.dirty ||
publishAfterSave ||
isFetching ? (
isFetching ||
saving ? (
<ButtonGroup
variant="contained"
color="success"
Expand Down
18 changes: 13 additions & 5 deletions src/apps/media/src/app/components/FileModal/RenameFileModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import {
} from "@mui/material";
import { alpha } from "@mui/material/styles";

import { withCursorPosition } from "../../../../../../shell/components/withCursorPosition";

const TextFieldWithCursorPosition = withCursorPosition(TextField);

interface Props {
handleUpdateMutation: (renamedFilename: string) => void;
onClose?: () => void;
Expand Down Expand Up @@ -72,7 +76,7 @@ export const RenameFileModal: FC<Props> = ({
</DialogTitle>
<DialogContent>
<InputLabel>New File Name</InputLabel>
<TextField
<TextFieldWithCursorPosition
sx={{
mt: 1,
width: "100%",
Expand All @@ -82,12 +86,16 @@ export const RenameFileModal: FC<Props> = ({
},
}}
autoFocus
onFocus={(evt) => evt.target.select()}
onFocus={(evt: React.FocusEvent<HTMLInputElement>) =>
evt.target.select()
}
value={renamedFilename}
onChange={(evt) => {
setRenamedFilename(evt.target.value);
onChange={(evt: React.ChangeEvent<HTMLInputElement>) => {
setRenamedFilename(evt.target.value.replace(" ", "-"));
}}
onKeyPress={(event) => event.key === "Enter" && handleUpdate()}
onKeyPress={(event: React.KeyboardEvent<HTMLDivElement>) =>
event.key === "Enter" && handleUpdate()
}
InputProps={{
disableUnderline: true,
endAdornment: (
Expand Down
10 changes: 8 additions & 2 deletions src/apps/media/src/app/components/Thumbnail/ThumbnailContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import {

import { alpha } from "@mui/material/styles";

import { withCursorPosition } from "../../../../../../shell/components/withCursorPosition";

const TextFieldWithCursorPosition = withCursorPosition(TextField);

interface Props {
filename: string;
onFilenameChange?: (value: string) => void;
Expand Down Expand Up @@ -45,13 +49,15 @@ export const ThumbnailContent: FC<Props> = ({
{onFilenameChange ? (
<Box>
<Box>
<TextField
<TextFieldWithCursorPosition
value={filename}
size="small"
variant="outlined"
fullWidth
disabled={!isEditable}
onChange={(e) => onFilenameChange(e.target.value)}
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
onFilenameChange(e.target.value.replace(" ", "-"))
}
sx={{
"& .MuiInputBase-root.MuiOutlinedInput-root": {
borderRadius: 0,
Expand Down

0 comments on commit c959f6c

Please sign in to comment.