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

Add "Enter Key" Functionality to Trigger Task Submission #209

Closed
wants to merge 4 commits into from
Closed
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
5 changes: 1 addition & 4 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ on:
pull_request:
branches:
- main

jobs:
format:
runs-on: ubuntu-latest
@@ -14,16 +11,18 @@ jobs:

steps:
- name: Checkout code
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/lint-and-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Lint and Format

on:
pull_request:
branches:
- main

jobs:
format:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '16' # You can specify the version you need

- name: Install dependencies
run: npm install --save-dev prettier

- name: Check formatting
run: npx prettier --check .

- name: Format code
run: npx prettier --write .
14 changes: 14 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,20 @@ document.addEventListener('DOMContentLoaded', () => {
const inputNameElement = document.querySelector('.js-name-input');
inputNameElement.focus();

// Add event listener for "Enter" key to trigger add or edit
document.querySelector('.js-name-input').addEventListener('keydown', (e) => {
if (e.key === 'Enter') {
if (isEditing) {
// If in edit mode, call addTodo to update the task
addTodo();
} else {
// If not in edit mode, call addTodo to add a new task
addTodo();
}
}
});


// Hide edit cancel action button on page load
const cancelEditBtn = document.querySelector('.js-cancel-button');
cancelEditBtn.style.display = 'none';
Expand Down
Loading