doing extra guards for actionMap and actionText range to ensure a valid ActionLabelAttribute gets created.

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2024-03-15 14:35:23 -05:00 committed by Scott Pfeil
parent 82b5c0e655
commit 20cd7acce2

View File

@ -421,6 +421,8 @@ extension Label {
/// Underlines the tappable region and stores the tap logic for interation.
private func setTextLinkState(range: NSRange, actionBlock: @escaping ActionBlock) {
guard range.length > 0 else { return }
var textLink = ActionLabelAttribute(location: range.location, length: range.length)
textLink.subscriber = textLink
.action
@ -440,6 +442,8 @@ extension Label {
}
public func createActionBlockFor(actionMap: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?) -> ActionBlock? {
guard let actionMap else { return nil }
return { [weak self] in
guard let self = self else { return }