Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
Todo-Storybook
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Madhankumar
Todo-Storybook
Commits
8173712a
Commit
8173712a
authored
Sep 20, 2023
by
Madhankumar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fix on task component
parent
6581c9f4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
15 deletions
+13
-15
db.json
db.json
+2
-2
index.js
src/components/top-level/task/index.js
+10
-12
task.css
src/components/top-level/task/task.css
+1
-1
No files found.
db.json
View file @
8173712a
...
...
@@ -6,12 +6,12 @@
"id"
:
1
},
{
"title"
:
"helloxxsxsxsxsxsxsxsxsxsxsxsxsxssssssssssssssssssssxssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssadddadsdsdsadasasasadasaadadadaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaavrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrryyyyy"
,
"title"
:
"helloxxsxsxsxsxsxsxsxsxsxsxsxsxssssssssssssssssssssxssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssadddadsdsdsadasasasadasaadadadaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaavrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrryyyyy
rt
"
,
"isCompleted"
:
false
,
"id"
:
2
},
{
"title"
:
"
hello
"
,
"title"
:
"
rfrfrfredefefefefffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
"
,
"isCompleted"
:
false
,
"id"
:
3
}
...
...
src/components/top-level/task/index.js
View file @
8173712a
import
{
FaTimesCircle
}
from
"react-icons/fa"
;
import
Checkbox
from
"../../base/checkbox"
;
import
"./task.css"
;
import
{
useEffect
,
useRef
,
useLayoutEffect
,
useState
,
useCallback
,
}
from
"react"
;
import
{
useEffect
,
useRef
,
useState
,
useCallback
}
from
"react"
;
function
Task
({
id
=
1
,
title
,
isCompleted
,
onChange
,
onDelete
})
{
const
[
debouncetitle
,
setDebounceTitle
]
=
useState
(
title
);
...
...
@@ -23,6 +17,8 @@ function Task({ id = 1, title, isCompleted, onChange, onDelete }) {
}
return
false
;
};
// (useCallback)---> to avoid calling the checkbox component without any action applied on checkbox
const
handleChange
=
useCallback
(()
=>
{
setIsCheck
(
!
ischeck
);
onChange
({
id
,
isCompleted
:
!
ischeck
});
...
...
@@ -31,6 +27,7 @@ function Task({ id = 1, title, isCompleted, onChange, onDelete }) {
const
handleContent
=
(
e
)
=>
{
setDebounceTitle
(
e
.
target
.
value
);
const
textarea
=
document
.
querySelector
(
"textarea"
);
//calculate the height of content based on scrollheight
textarea
.
addEventListener
(
"keyup"
,
(
e
)
=>
{
let
scheight
=
e
.
target
.
scrollHeight
;
textarea
.
style
.
height
=
`
${
scheight
}
px`
;
...
...
@@ -39,6 +36,11 @@ function Task({ id = 1, title, isCompleted, onChange, onDelete }) {
//debounce
useEffect
(()
=>
{
//checking the content height and set on page load
const
scrollHeight
=
textarea_ref
.
current
.
scrollHeight
;
textarea_ref
.
current
.
style
.
height
=
`
${
scrollHeight
}
px`
;
//after 2 second it will execute
const
handler
=
setTimeout
(()
=>
{
if
(
textarea_ref
.
current
.
value
!=
title
)
{
onChange
({
id
,
title
:
debouncetitle
});
...
...
@@ -50,10 +52,6 @@ function Task({ id = 1, title, isCompleted, onChange, onDelete }) {
};
},
[
debouncetitle
]);
useLayoutEffect
(()
=>
{
const
scrollHeight
=
textarea_ref
.
current
.
scrollHeight
;
textarea_ref
.
current
.
style
.
height
=
`
${
scrollHeight
}
px`
;
},
[
debouncetitle
]);
return
(
<
div
className
=
"task-section"
>
<
div
>
...
...
@@ -69,7 +67,7 @@ function Task({ id = 1, title, isCompleted, onChange, onDelete }) {
contentEditable
=
{
true
}
value
=
{
debouncetitle
}
onChange
=
{
handleContent
}
disabled
=
{
ischeck
}
//
disabled={ischeck}
><
/textarea
>
<
/div
>
<
FaTimesCircle
className
=
"fa-close"
onClick
=
{
handleDelete
}
/
>
...
...
src/components/top-level/task/task.css
View file @
8173712a
...
...
@@ -10,7 +10,7 @@
.task-section
>
div
{
display
:
flex
;
align-items
:
center
;
width
:
5
0%
;
width
:
9
0%
;
}
.fa-close
{
color
:
#ccc
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment