-
Notifications
You must be signed in to change notification settings - Fork 101
Design for message-list typing indication #12418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| <!doctype html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>Messages</title> | ||
| <script type="module" src="../common.js"></script> | ||
|
|
||
| <script type="module"> | ||
| import '@vaadin/checkbox-group'; | ||
| import '@vaadin/message-input'; | ||
| import '@vaadin/message-list'; | ||
| import '@vaadin/tooltip'; | ||
| import '@vaadin/component-base/src/styles/user-colors.js'; | ||
|
|
||
| const list = document.querySelector('vaadin-message-list'); | ||
| list.items = [ | ||
| { | ||
| text: 'Nature does not hurry, yet everything gets accomplished.', | ||
| time: 'yesterday', | ||
| userName: 'Matt Mambo', | ||
| userColorIndex: 1, | ||
| theme: 'self', | ||
| }, | ||
| { | ||
| text: "I've reviewed your Q3 financial documents. Here's a summary:\n\n**Key Findings:**\n- Revenue increased 12% compared to Q2\n- Operating costs remained stable\n- The chart shows positive growth trends\n\n**Concerns:**\n- Marketing spend is 15% over budget\n- Cash flow projections need revision\n\nWould you like me to elaborate on any of these points?", | ||
| time: 'right now', | ||
| userName: 'Assistant', | ||
| theme: 'full-width', | ||
| }, | ||
| { | ||
| text: 'Using your talent, hobby or profession in a way that makes you contribute with something good to this world is truly the way to go.', | ||
| time: 'right now', | ||
| userName: 'Linsey Listy', | ||
| userColorIndex: 2, | ||
| }, | ||
| ]; | ||
|
|
||
| const input = document.querySelector('vaadin-message-input'); | ||
| input.addEventListener('submit', (e) => { | ||
| const message = e.detail.value; | ||
| list.items = [ | ||
| ...list.items, | ||
| { | ||
| text: message, | ||
| time: 'now', | ||
| userName: 'You', | ||
| userColorIndex: 0, | ||
| }, | ||
| ]; | ||
| }); | ||
|
|
||
| document.querySelector('#variant').addEventListener('change', function () { | ||
| list.setAttribute('theme', this.value.join(' ')); | ||
| }); | ||
| </script> | ||
| </head> | ||
|
|
||
| <body> | ||
| <vaadin-checkbox-group label="Variant" id="variant"> | ||
| <vaadin-checkbox label="Bubble" value="bubble"></vaadin-checkbox> | ||
| <vaadin-checkbox label="One to One" value="one-to-one"></vaadin-checkbox> | ||
| </vaadin-checkbox-group> | ||
| <h2 class="heading">Default</h2> | ||
| <vaadin-message-list announce-messages markdown> | ||
| <vaadin-message slot="typing-indicator" typing user-name="Assistant"><span>Typing…</span></vaadin-message> | ||
| <vaadin-message slot="typing-indicator" typing user-name="Assistant" theme="ellipsis"><span>Typing…</span></vaadin-message> | ||
| <vaadin-message slot="typing-indicator" typing user-name="Assistant" theme="text"><span>Typing…</span></vaadin-message> | ||
| </vaadin-message-list> | ||
| <vaadin-message-input> | ||
| <vaadin-tooltip slot="tooltip" text="Press Enter to send"></vaadin-tooltip> | ||
| </vaadin-message-input> | ||
| <h2 class="heading">Icon-Button Variant</h2> | ||
| <vaadin-message-input theme="icon-button"></vaadin-message-input> | ||
| </body> | ||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -124,6 +124,8 @@ export const MessageInputMixin = (superClass) => | |
|
|
||
| this._tooltipController = new TooltipController(this); | ||
| this.addController(this._tooltipController); | ||
|
|
||
| this.addEventListener('click', () => this._textArea.focus()); | ||
| } | ||
|
|
||
| focus(options) { | ||
|
|
@@ -136,7 +138,11 @@ export const MessageInputMixin = (superClass) => | |
| __buttonPropsChanged(button, disabled, effectiveI18n, value) { | ||
| if (button) { | ||
| button.disabled = disabled || !value; | ||
| button.textContent = effectiveI18n.send; | ||
| if (button.localName === 'vaadin-message-input-button') { | ||
| button.textContent = effectiveI18n.send; | ||
| } else if (button.textContent.trim().length === 0) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
A developer supplies The branch also never clears the label: a button that starts icon-only (gets vaadin-message-input-mixin.js:143 · |
||
| button.setAttribute('aria-label', effectiveI18n.send); | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clicklistener runsthis._textArea.focus()for any click anywhere in the component, including the new slotted controls.This PR adds
header,prefix,footer, and custombuttonslots that hold interactive controls (in the dev demo: a paperclip upload button inprefix, an upload-file-list inheader, prompt buttons infooter). Clicking any of them bubbles to the host and immediately pulls focus into the textarea, so the control the user just activated loses focus.This hurts keyboard and screen-reader users and is generically wrong — the intent (focus the textarea when clicking the input's own padding) should be limited to the host itself, not the whole slotted subtree.
vaadin-message-input-mixin.js:128 ·
correctness·confirmed