Pad random color with leading zeroes

Fixes issue with color validation when leading zeroes are missing.

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
This commit is contained in:
Vincent Petry
2021-01-13 09:33:30 +01:00
parent 5bbf96eab1
commit 9ced6ae8c6

View File

@@ -39,7 +39,13 @@
<script>
import { ColorPicker, ActionButton, Actions, AppNavigationItem } from '@nextcloud/vue'
const randomColor = () => '#' + ((1 << 24) * Math.random() | 0).toString(16)
function randomColor() {
let randomHexColor = ((1 << 24) * Math.random() | 0).toString(16)
while (randomHexColor.length < 6) {
randomHexColor = '0' + randomHexColor
}
return '#' + randomHexColor
}
export default {
name: 'AppNavigationAddBoard',