Skip to content
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

Regions plugin: Only add resize handles if resize prop is true #3171

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions cypress/e2e/regions.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,23 @@ describe('WaveSurfer Regions plugin tests', () => {
win.wavesurfer.destroy()
})
})

it('should not add resize handles if resize is set to false', () => {
cy.window().then((win) => {
const regionsPlugin = win.wavesurfer.getActivePlugins()[0]

const region = regionsPlugin.addRegion({
id: 'no-resize-region',
start: 1,
end: 5,
resize: false,
})

expect(region).to.be.an('object')
expect(region.element).to.be.an('HTMLDivElement')
expect(region.element.children).to.have.length(0)

win.wavesurfer.destroy()
})
})
})
2 changes: 1 addition & 1 deletion src/plugins/regions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class SingleRegion extends EventEmitter<RegionEvents> {
)

// Add resize handles
if (!isMarker) {
if (!isMarker && this.resize) {
const leftHandle = document.createElement('div')
leftHandle.setAttribute('data-resize', 'left')
leftHandle.setAttribute(
Expand Down