Commit 558b11e7e152891f436d17180335e54c3701aa6b
Fixes inconsistent behavior
These changes help improve the consistency of the new channel-input The compose box now stays open when left empty and inputing a channel. The # sigil is added if it's not the first character inputted and is kept after confirming a suggestion.Bradley Donahue committed on 2/5/2017, 7:06:27 PM
Parent: 9429dd07ea740e2d002c966affa5cdaccc0d73f3
Files changed
modules_basic/compose.js | changed |
modules_basic/compose.mcss | changed |
modules_extra/channel.js | changed |
modules_basic/compose.js | ||
---|---|---|
@@ -49,11 +49,22 @@ | ||
49 | 49 … | }) |
50 | 50 … | |
51 | 51 … | var channelInput = h('input.channel', { |
52 | 52 … | placeholder: '#channel', |
53 | - value: meta.channel || '' | |
53 … | + value: meta.channel ? `#${meta.channel}` : '', | |
54 … | + disabled: meta.channel ? true : false | |
54 | 55 … | }) |
55 | 56 … | |
57 … | + channelInput.addEventListener('keydown', function (e) { | |
58 … | + console.log(e) | |
59 … | + if (this.value.startsWith('#') && this.value.length === 1) { | |
60 … | + this.value = '' | |
61 … | + return | |
62 … | + } | |
63 … | + if (this.value.startsWith('#')) return | |
64 … | + this.value = `#${this.value}` | |
65 … | + }) | |
66 … | + | |
56 | 67 … | if(opts.shrink !== false) { |
57 | 68 … | var blur |
58 | 69 … | textArea.addEventListener('focus', () => { |
59 | 70 … | clearTimeout(blur) |
@@ -69,8 +80,21 @@ | ||
69 | 80 … | if(textArea.value) return |
70 | 81 … | composer.className = 'Compose -contracted' |
71 | 82 … | }, 300) |
72 | 83 … | }) |
84 … | + channelInput.addEventListener('focus', () => { | |
85 … | + clearTimeout(blur) | |
86 … | + if (!textArea.value) { | |
87 … | + composer.className = 'Compose -expanded' | |
88 … | + } | |
89 … | + }) | |
90 … | + channelInput.addEventListener('blur', () => { | |
91 … | + clearTimeout(blur) | |
92 … | + blur = setTimeout(() => { | |
93 … | + if (textArea.value || channelInput.value) return | |
94 … | + composer.className = 'Compose -contracted' | |
95 … | + }, 300) | |
96 … | + }) | |
73 | 97 … | } |
74 | 98 … | |
75 | 99 … | textArea.addEventListener('keydown', ev => { |
76 | 100 … | if(ev.keyCode === 13 && ev.ctrlKey) publish() |
Built with git-ssb-web