Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.
Merged
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
2 changes: 2 additions & 0 deletions lib/depject/message/html/compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ exports.create = function (api) {
contentWarningInput.value = ''
refreshHasContent()
save()
} else {
textArea.focus()
}
if (cb) cb(null, msg)
}
Expand Down
19 changes: 17 additions & 2 deletions lib/depject/message/sheet/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ exports.create = function (api) {
// allow inspecting of raw message that is about to be sent
messageElement.msg = msg

const cancelButton = h('button -cancel', { 'ev-click': cancel }, i18n('Cancel'))
return {
content: [
messageElement
Expand Down Expand Up @@ -73,8 +74,22 @@ exports.create = function (api) {
])
),
h('button -save', { 'ev-click': publish }, i18n('Confirm')),
h('button -cancel', { 'ev-click': cancel }, i18n('Cancel'))
]
cancelButton
],
onMount: () => {
cancelButton.focus()
},
attributes: {
'ev-keydown': ev => {
if (ev.key === 'Enter' && (ev.ctrlKey || ev.metaKey)) {
publish()
ev.preventDefault()
} else if (ev.key === 'Escape') {
cancel()
ev.preventDefault()
}
}
}
}

function publish () {
Expand Down
8 changes: 6 additions & 2 deletions lib/depject/sheet/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ exports.gives = nest('sheet.display')

exports.create = function () {
return nest('sheet.display', function (handler) {
const { content, footer, classList, onMount } = handler(done)
const { content, footer, classList, onMount, attributes } = handler(done)

const container = h('div', { className: 'Sheet', classList }, [
let fullAttributes = { className: 'Sheet', classList }
if (attributes !== undefined) {
fullAttributes = { ...attributes, ...fullAttributes }
}
const container = h('div', fullAttributes, [
Comment on lines +10 to +14
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like it could be cleaner. I'm passing the classList and the attributes separately just to have them be recombined...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, could I maybe attache the event handlers (passed as attributes) to something else that makes more sense?

h('section', [content]),
h('footer', [footer])
])
Expand Down