Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed edit for hints #462

Merged
merged 1 commit into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/src/models/Hint.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module.exports = (sequelize, DataTypes) => {
},
},
hintContent: {
type: DataTypes.STRING,
type: DataTypes.STRING(1024),
allowNull: false,
defaultValue: "",
},
Expand Down
27 changes: 11 additions & 16 deletions frontend/src/components/DropdownList/DropdownList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,19 @@ const DropdownList = ({

const [selectedAction, setSelectedAction] = useState('');

useEffect(() => {
const getInitialSelectedAction = () => {
if (selectedActionString) {
const index = actions.findIndex(action =>
action.toLowerCase() === selectedActionString.toLowerCase()
);
return index !== -1 ? actions[index] : actions[0] || "";
}
return actions[selectedActionIndex] || "";
};
setSelectedAction(getInitialSelectedAction());
}, []);
const getInitialSelectedAction = () => {
if (selectedActionString) {
const index = actions.findIndex(action =>
action.toLowerCase() === selectedActionString.toLowerCase()
);
return index !== -1 ? actions[index] : actions[0] || "";
}
return actions[selectedActionIndex] || "";
};

useEffect(() => {
if (onActionChange) {
onActionChange(selectedAction);
}
}, [selectedAction, onActionChange]);
setSelectedAction(getInitialSelectedAction());
}, [selectedActionString]);

const handleChange = (event) => {
const newValue = event.target.value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const HintLeftContent = ({ actionButtonText, setActionButtonText, actionButtonUr
setAction(newAction);
};

const handleTargetElement = (newAction) => {
setTargetElement(newAction);
const handleTargetElement = (event) => {
setTargetElement(event.target.value);
};

const handleTooltipPlacement = (newAction) => {
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/scenes/hints/CreateHintPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ const HintPage = ({ autoOpen = false, isEdit, itemId, setItemsUpdated, setIsEdit
setUrl(hintData.url || "https://");
setActionButtonText(hintData.actionButtonText || "");
setAction(hintData.action || "No action");
setTargetElement(hintData.targetElement || '.element')
setTooltipPlacement(hintData.tooltipPlacement || 'Top')
} catch (error) {
emitToastError(error);
}
Expand Down
Loading