Skip to content

Commit

Permalink
fix: handle null displayname (openedx#1074)
Browse files Browse the repository at this point in the history
  • Loading branch information
rayzhou-bit authored Jun 7, 2024
1 parent 7aa2baa commit 7f5e82a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const ComponentModalView = ({
<ModalContainer
isOpen={isOpen}
close={close}
title={intl.formatMessage(messages.modalContainerTitle, { componentTitle: displayName.toLowerCase() })}
title={intl.formatMessage(messages.modalContainerTitle, { componentTitle: (displayName ?? '').toLowerCase() })}
btnText={intl.formatMessage(messages.modalBtnText)}
onSubmit={handleSubmit}
resetDisabled={() => setModuleTitle('')}
Expand Down
2 changes: 1 addition & 1 deletion src/studio-home/card-item/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const CardItem = ({
const isShowRerunLink = allowCourseReruns
&& rerunCreatorStatus
&& courseCreatorStatus === COURSE_CREATOR_STATES.granted;
const hasDisplayName = displayName.trim().length ? displayName : courseKey;
const hasDisplayName = (displayName ?? '').trim().length ? displayName : courseKey;

return (
<Card className="card-item">
Expand Down
7 changes: 5 additions & 2 deletions src/studio-home/tabs-section/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
* @returns {array} - An array of alphabetically sorted courses or libraries.
*/
const sortAlphabeticallyArray = (arr) => [...arr]
.sort((firstArrayData, secondArrayData) => firstArrayData
.displayName.localeCompare(secondArrayData.displayName));
.sort((firstArrayData, secondArrayData) => {
const firstDisplayName = firstArrayData.displayName ?? '';
const secondDisplayName = secondArrayData.displayName ?? '';
return firstDisplayName.localeCompare(secondDisplayName);
});

// eslint-disable-next-line import/prefer-default-export
export { sortAlphabeticallyArray };

0 comments on commit 7f5e82a

Please sign in to comment.