Skip to content

Commit c65844d

Browse files
Copilotalexr00
andcommitted
Move constant to shared constants file to avoid duplication
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 121ed42 commit c65844d

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

webviews/common/constants.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
/**
7+
* Key for tracking comment textarea focus state in sessionStorage.
8+
* Used to restore focus when the PR description webview regains focus.
9+
*/
10+
export const COMMENT_TEXTAREA_FOCUS_KEY = 'comment-textarea-had-focus';

webviews/common/context.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,14 @@
55

66
import { createContext } from 'react';
77
import { getState, setState, updateState } from './cache';
8+
import { COMMENT_TEXTAREA_FOCUS_KEY } from './constants';
89
import { getMessageHandler, MessageHandler } from './message';
910
import { CloseResult, OpenCommitChangesArgs } from '../../common/views';
1011
import { IComment } from '../../src/common/comment';
1112
import { EventType, ReviewEvent, SessionLinkInfo, TimelineEvent } from '../../src/common/timelineEvent';
1213
import { IProjectItem, MergeMethod, ReadyForReview } from '../../src/github/interface';
1314
import { CancelCodingAgentReply, ChangeAssigneesReply, DeleteReviewResult, MergeArguments, MergeResult, ProjectItemsReply, PullRequest, ReadyForReviewReply, SubmitReviewReply } from '../../src/github/views';
1415

15-
// Key for tracking comment textarea focus state in sessionStorage
16-
// Also used in webviews/editorWebview/app.tsx
17-
const COMMENT_TEXTAREA_FOCUS_KEY = 'comment-textarea-had-focus';
18-
1916
export class PRContext {
2017
constructor(
2118
public pr: PullRequest | undefined = getState(),

webviews/editorWebview/app.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@ import React, { useContext, useEffect, useState } from 'react';
88
import { render } from 'react-dom';
99
import { Overview } from './overview';
1010
import { PullRequest } from '../../src/github/views';
11+
import { COMMENT_TEXTAREA_FOCUS_KEY } from '../common/constants';
1112
import PullRequestContext from '../common/context';
1213

13-
// Key for tracking comment textarea focus state in sessionStorage
14-
// Also used in webviews/common/context.tsx
15-
const COMMENT_TEXTAREA_FOCUS_KEY = 'comment-textarea-had-focus';
16-
1714
export function main() {
1815
render(<Root>{pr => <Overview {...pr} />}</Root>, document.getElementById('app'));
1916
}

0 commit comments

Comments
 (0)