Adaverse commented on code in PR #30950:
URL: https://github.com/apache/airflow/pull/30950#discussion_r1205934472
##########
airflow/www/static/js/dag/details/NotesAccordion.tsx:
##########
@@ -80,12 +89,56 @@ const NotesAccordion = ({
setEditMode(false);
};
+ const toggleNotesAccordionIthIndex = (ithIndex: number) => {
+ if (accordionIndexes.includes(ithIndex)) {
+ setAccordionIndexes((prevIndexes) =>
+ prevIndexes.splice(prevIndexes.indexOf(ithIndex, 1))
+ );
+ } else {
+ setAccordionIndexes((prevIndexes) => [...prevIndexes, ithIndex]);
+ }
+ };
+
+ useKeysPress(
+ keyboardShortcutIdentifier.addOrEditNotes.primaryKey,
+ keyboardShortcutIdentifier.addOrEditNotes.secondaryKey,
+ () => {
+ if (canEdit) {
+ // Notes index is 0
+ if (!accordionIndexes.includes(0)) {
+ toggleNotesAccordionIthIndex(0);
+ }
+ setEditMode(true);
+ setTimeout(() => textAreaRef.current?.focus(), 100);
+ }
+ }
+ );
+
+ useKeysPress(
+ keyboardShortcutIdentifier.viewNotes.primaryKey,
+ keyboardShortcutIdentifier.viewNotes.secondaryKey,
+ () => {
+ // toggling notes accordion (index = 0)
+ toggleNotesAccordionIthIndex(0);
Review Comment:
True! But implemented `toggleNotesAccordionIthIndex`, thinking new panels
might be included in the accordion in the future. Since you think that it might
be overkill, hence replaced it with the simplest implementation -
`toggleNotesPanel`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]