-
Notifications
You must be signed in to change notification settings - Fork 420
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
Fix tooltip appearance for long names in ConversationList #8605
Fix tooltip appearance for long names in ConversationList #8605
Conversation
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
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.
We don't use inline if's in Nextcloud :)
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
@@ -302,6 +303,23 @@ export default { | |||
} | |||
}, | |||
}, | |||
|
|||
// TODO: move the implementation to @nextcloud-vue/NcListItem |
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.
Waiting for discussion of nextcloud-libraries/nextcloud-vue#3687, if the same approach could be implemented there
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <antreesy.web@gmail.com>
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 antreesy.web@gmail.com
Fix #7254
Due to using the NcListItem component with title locked for modifications, we don't have opportunities to add
v-tooltip
here.So, HTML-attribute
title
was 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