@@ -31,6 +31,7 @@ def initialize(tag: DEFAULT_TAG, align: ALIGN_DEFAULT, tooltipped: false, body_a
3131 @system_arguments = system_arguments
3232 @tooltipped = tooltipped
3333 @body_arguments = body_arguments
34+ @direction = @body_arguments [ :direction ]
3435
3536 body_tag = @body_arguments [ :tag ] || DEFAULT_BODY_TAG
3637 @body_arguments [ :tag ] = fetch_or_fallback ( BODY_TAG_OPTIONS , body_tag , DEFAULT_BODY_TAG )
@@ -45,14 +46,27 @@ def initialize(tag: DEFAULT_TAG, align: ALIGN_DEFAULT, tooltipped: false, body_a
4546 system_arguments [ :classes ] ,
4647 "AvatarStack--right" => @align == :right
4748 )
49+
50+ @body_arguments [ :tabindex ] = tooltipped ? 0 : nil
51+ @body_arguments [ :id ] = tooltipped ? @body_arguments [ :id ] ||= self . class . generate_id : @body_arguments [ :id ]
52+
53+ @tooltip_arguments = {
54+ for_id : @body_arguments [ :id ] ,
55+ }
56+
57+ @tooltip_arguments [ :direction ] = @direction || Primer ::Alpha ::Tooltip ::DIRECTION_DEFAULT
58+ @tooltip_arguments [ :text ] = @body_arguments [ :label ]
59+ @tooltip_arguments [ :type ] = :description
60+
61+ @body_arguments [ :aria ] ||= { }
62+ if tooltipped && @body_arguments [ :label ] . present?
63+ @body_arguments [ :aria ] [ :label ] = @body_arguments [ :label ]
64+ @body_arguments [ :label ] = nil
65+ end
4866 end
4967
5068 def body_component
51- if @tooltipped
52- Primer ::Tooltip . new ( **@body_arguments ) # rubocop:disable Primer/ComponentNameMigration
53- else
54- Primer ::BaseComponent . new ( **@body_arguments )
55- end
69+ Primer ::BaseComponent . new ( **@body_arguments )
5670 end
5771
5872 def before_render
0 commit comments