From 90d76fb5befc6a60449d362047de0a0f85de3195 Mon Sep 17 00:00:00 2001 From: imsyf Date: Mon, 22 Feb 2021 10:05:02 +0700 Subject: [PATCH] Set color picker default value to black I noticed that color picker HTML element retains the last picked value from user even after the page is reloaded. This will cause inconsistency between `color` value and the actual `colorEl.value`. This commit will always initialize color picker default value to black, the same way that `color` variable was set originally. --- drawing-app/script.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drawing-app/script.js b/drawing-app/script.js index cb66181..f9f4389 100644 --- a/drawing-app/script.js +++ b/drawing-app/script.js @@ -9,7 +9,8 @@ const ctx = canvas.getContext('2d'); let size = 10 let isPressed = false -let color = 'black' +colorEl.value = 'black' +let color = colorEl.value let x let y