Fix tooltip appearance for long names in ConversationList#8605
Conversation
Signed-off-by: Maksim Sukharev <[email protected]>
Signed-off-by: Maksim Sukharev <[email protected]>
nickvergessen
left a comment
There was a problem hiding this comment.
We don't use inline if's in Nextcloud :)
Signed-off-by: Maksim Sukharev <[email protected]>
| }, | ||
| }, | ||
|
|
||
| // TODO: move the implementation to @nextcloud-vue/NcListItem |
There was a problem hiding this comment.
Waiting for discussion of nextcloud-libraries/nextcloud-vue#3687, if the same approach could be implemented there
ShGKme
left a comment
There was a problem hiding this comment.
Everything is good for me now. Only one small comment about optional chaining.
| const titleSpan = this.$refs.listItem?.$el?.querySelector('.line-one__title') | ||
|
|
There was a problem hiding this comment.
If $refs.listItem is always defined, then all optional chainings ?. are redundant.
But if $refs.listItem maybe undefined, then it will fail anyway with a call of undefined. In such a case, it should have optional chaining on the function call querySelector?.('.line-one__title').
<NcListItem> is always rendered: there is no v-if on it or anything. IMO, we may drop checking with optional chaining here.
|
Added Thanks to @ShGKme for the suggestion |
Signed-off-by: Maksim Sukharev <[email protected]>
For the record. What happens in the test:
const action = shallowMountAndGetAction('Leave conversation')
await action.find('button').trigger('click')
expect(actionHandler).toHaveBeenCalled()What was not correct: A promise of the async handler is not related to the nextTick's promise. Waiting for async in Vue reactivity doesn't guarantee some async method (handler) to be resolved. What is correct: Wait for the handler's promise to be resolved. It's not easy to do. But waiting for all promises to be resolved works fine, and that is a common practice. Why it worked previously and failed after the update in this PR: The async handler was kind of the only async process in the component. Waiting for the
Calling
Adding waiting for literally any promise would work too. await action.find('button').trigger('click')
await Promise.resolve() // Even this is enough to wait for the end of microtasks queue in this case |
|
/backport to stable25 |
| const titleSpan = this.$refs.listItem?.$el?.querySelector('.line-one__title') | ||
|
|
||
| if (titleSpan && titleSpan.offsetWidth < titleSpan.scrollWidth) { | ||
| titleSpan.setAttribute('title', value) |
There was a problem hiding this comment.
All this just to set the title attribute? It would be a minor change in the nextcloud-vue lib to add this there without the need for watch and querySelector.
There was a problem hiding this comment.
As I know, it is not possible to detect if a text fit container or not without putting it in the container and looking at the result in DOM. watch + DOM access could be missed only if a title is always shown independently from title length.
But a change in nextcloud-vue may help to avoid manual mutating of Vue-rendered DOM.
Signed-off-by: Maksim Sukharev [email protected]
Fix #7254
Due to using the NcListItem component with title locked for modifications, we don't have opportunities to add
v-tooltiphere.So, HTML-attribute
titlewas applied for long names to show tooltip via native browser tools, when name is ellipsed.!IMPORTANT
Current realisation works only if name is ellipsed initially (action button appears on hover and crops name even more)
🖼️ Screenshots
🚧 TODO
🏁 Checklist
docs/has been updated or is not required