mirror of
				https://github.com/advplyr/audiobookshelf.git
				synced 2025-10-27 11:18:14 +01:00 
			
		
		
		
	Make Tooltips Accessible
When using accessibility tools like screen magnifiers, dynamic screen content can be quite problematic. In particular content, which only appears if you interact with elements somewhere else on the screen. That is the case, for example, with the current implementation of tooltips used by audiobookshelf. This patch provides a slight adjustment, keeping the tooltips open if you hover over them. This allows users to have better access to the content.
This commit is contained in:
		
							parent
							
								
									b648155170
								
							
						
					
					
						commit
						ee0ac00f80
					
				| @ -21,7 +21,8 @@ export default { | |||||||
|     return { |     return { | ||||||
|       tooltip: null, |       tooltip: null, | ||||||
|       tooltipId: null, |       tooltipId: null, | ||||||
|       isShowing: false |       isShowing: false, | ||||||
|  |       hideTimeout: null | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|   watch: { |   watch: { | ||||||
| @ -46,10 +47,12 @@ export default { | |||||||
|       var tooltip = document.createElement('div') |       var tooltip = document.createElement('div') | ||||||
|       this.tooltipId = String(Math.floor(Math.random() * 10000)) |       this.tooltipId = String(Math.floor(Math.random() * 10000)) | ||||||
|       tooltip.id = this.tooltipId |       tooltip.id = this.tooltipId | ||||||
|       tooltip.className = 'tooltip-wrapper absolute px-2 py-1 text-white pointer-events-none text-xs rounded shadow-lg max-w-xs text-center hidden sm:block' |       tooltip.className = 'tooltip-wrapper absolute px-2 py-1 text-white text-xs rounded shadow-lg max-w-xs text-center hidden sm:block' | ||||||
|       tooltip.style.zIndex = 100 |       tooltip.style.zIndex = 100 | ||||||
|       tooltip.style.backgroundColor = 'rgba(0,0,0,0.85)' |       tooltip.style.backgroundColor = 'rgba(0,0,0,0.85)' | ||||||
|       tooltip.innerHTML = this.text |       tooltip.innerHTML = this.text | ||||||
|  |       tooltip.addEventListener('mouseover', this.cancelHide); | ||||||
|  |       tooltip.addEventListener('mouseleave', this.hideTooltip); | ||||||
| 
 | 
 | ||||||
|       this.setTooltipPosition(tooltip) |       this.setTooltipPosition(tooltip) | ||||||
| 
 | 
 | ||||||
| @ -95,6 +98,7 @@ export default { | |||||||
|       } catch (error) { |       } catch (error) { | ||||||
|         console.error(error) |         console.error(error) | ||||||
|       } |       } | ||||||
|  | 
 | ||||||
|       this.isShowing = true |       this.isShowing = true | ||||||
|     }, |     }, | ||||||
|     hideTooltip() { |     hideTooltip() { | ||||||
| @ -102,11 +106,16 @@ export default { | |||||||
|       this.tooltip.remove() |       this.tooltip.remove() | ||||||
|       this.isShowing = false |       this.isShowing = false | ||||||
|     }, |     }, | ||||||
|  |     cancelHide() { | ||||||
|  |       if (this.hideTimeout) clearTimeout(this.hideTimeout); | ||||||
|  |     }, | ||||||
|     mouseover() { |     mouseover() { | ||||||
|       if (!this.isShowing) this.showTooltip() |       if (!this.isShowing) this.showTooltip() | ||||||
|     }, |     }, | ||||||
|     mouseleave() { |     mouseleave() { | ||||||
|       if (this.isShowing) this.hideTooltip() |       if (this.isShowing) { | ||||||
|  |         this.hideTimeout = setTimeout(this.hideTooltip, 100) | ||||||
|  |       } | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|   beforeDestroy() { |   beforeDestroy() { | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user